Skip to content

Style check on c793fcd24978135ad5c7e268d0fd56d25bee73ea #51

Style check on c793fcd24978135ad5c7e268d0fd56d25bee73ea

Style check on c793fcd24978135ad5c7e268d0fd56d25bee73ea #51

Workflow file for this run

name: Check Style
run-name: Style check on ${{ github.sha }}
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: write
pull-requests: write
jobs:
Style-Check:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- name: Install tools
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends yamllint
- name: Set up JDK 19
uses: actions/setup-java@v4
with:
java-version: '19'
distribution: 'temurin'
- name: Create gradle.properties
run: |
mkdir -p ~/.gradle
echo "RELEASE_STORE_FILE=notExisting.jks" >~/.gradle/gradle.properties
echo "RELEASE_STORE_PASSWORD=unused" >>~/.gradle/gradle.properties
echo "RELEASE_KEY_ALIAS=unused" >>~/.gradle/gradle.properties
echo "RELEASE_KEY_PASSWORD=unused" >>~/.gradle/gradle.properties
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Verify Google Java format
run: ./gradlew verifyGoogleJavaFormat
- name: Check yaml style
run: yamllint .
- name: Format Java code
if: ${{ (github.event_name == 'push') && (success() || failure()) }}
run: ./gradlew googleJavaFormat
- name: Create pull request
if: ${{ (github.event_name == 'push') && (success() || failure()) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
[[ -z "$(git status -s)" ]] && echo No changes && exit 0
curr_branch="${{ github.head_ref || github.ref_name }}"
new_branch="auto-format-$(git rev-parse HEAD | head -c 8)"
author_name="$(git log -1 --pretty=format:'%an')"
author_email="$(git log -1 --pretty=format:'%ae')"
git checkout -b "$new_branch" && git merge "$curr_branch"
git config user.name "$author_name"
git config user.email "$author_email"
git remote set-url origin "https://github.com/${{ github.repository }}"
git commit -am 'Apply code formatting automatically from GitHub actions'
git push origin "$new_branch"
gh pr create -B "$curr_branch" -H "$new_branch" --title "Merge \`$new_branch\` into \`$curr_branch\`" \
--body 'Apply code formatting [generated automatically]'