Skip to content

Add: Workflow for code format checking #1

Add: Workflow for code format checking

Add: Workflow for code format checking #1

name: "Google-java-format"
run-name: ""
on:
push:
branches:
- "*"
branches_ignore:
- "main"
- "develop"
pull_request:
branches:
- "*"
env:
VERSION: 1.22.0
jobs:
format: # job_id
name: java-format-check
if: github.repository == 's-bose7/open-banking-suite'
runs-on: ubuntu-latest
steps:
- name: Set up JDK 11
uses: actions/setup-java@v4
with:

Check failure on line 25 in .github/workflows/google-java-format.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/google-java-format.yml

Invalid workflow file

You have an error in your yaml syntax on line 25
java-version: 11
distribution: 'temurin'
- name: Checkout Pull Request Code
uses: actions/checkout@v4
- uses: robinraju/release-downloader@v1
with:
repository: 'google/google-java-format'
tag: "v${{env.VERSION}}"
fileName: "google-java-format-${{env.VERSION}}-all-deps.jar"
out-file-path: '.ci-temp'
- name: Get list of modified Java files
id: changed_files
run: |
git fetch --depth=1 origin ${{ github.event.pull_request.base.ref }}
git diff --name-only --diff-filter=d FETCH_HEAD | grep '.java$' > changed_files.txt
- name: Run Formatting
if: success()
run: |
if [ -s changed_files.txt ]; then
java -jar .ci-temp/google-java-format-${{env.VERSION}}-all-deps.jar --replace $(cat changed_files.txt)
else
echo "No Java files changed, skipping formatting check."
fi
- name: Cleanup
if: always()
run: |
rm -rf .ci-temp
rm -f changed_files.txt