-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into contribute-frequency-and-angle-qks
- Loading branch information
Showing
2 changed files
with
77 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Format sources and commit to branch | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
# setting the environment on the job is mandatory, otherwise it cannot access environment secrets. | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check write access to repo | ||
run: | | ||
token_login=$(curl -H "Authorization: Bearer ${token}" https://api.github.com/user | jq -r '.login') | ||
echo token login is ${token_login} | ||
echo $(curl -H "Authorization: Bearer ${token}" https://api.github.com/repos/${repo}/collaborators/${token_login}/permission) > result | ||
cat result | jq '.permission == "admin" // .permission == "write"' > /dev/null || ( echo "Token does not have write access to ${repo}" >> ${GITHUB_STEP_SUMMARY}; exit 1) | ||
curl -sS -f -I -H "Authorization: Bearer ${token}" https://api.github.com | grep 'x-oauth-scopes:' | grep 'repo' > /dev/null && exit 0 || echo "Token does not have repo scope on ${repo}" >> ${GITHUB_STEP_SUMMARY} | ||
env: | ||
repo: ${{ github.repository }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Set up java with maven cache | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
cache: 'maven' | ||
|
||
# configure git | ||
- name: Setup git config | ||
run: | | ||
git config user.name ${{ github.actor }} | ||
git config user.email "<>" | ||
# Check formatting and exit early (with success) if format is ok | ||
- name: Check formatting | ||
run: mvn spotless:check && ( echo "Source was already formatted, nothing was touched." >> $GITHUB_STEP_SUMMARY ; exit 0 ) | ||
|
||
# Apply formatting (changelog was touched) | ||
- name: Apply formatting | ||
run: mvn spotless:apply | ||
|
||
# Commit changes | ||
- name: Commit changes | ||
run: git commit -m "Apply formatting rules" | ||
|
||
# Push changes to branch | ||
- name: Push changes to branch | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: git push origin | ||
|
||
# print the summary | ||
- name: Print summary | ||
run: echo "Successfully formatted the source files and made a commit." >> $GITHUB_STEP_SUMMARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters