Skip to content

[DOP-16959] - update documentation (#7) #16

[DOP-16959] - update documentation (#7)

[DOP-16959] - update documentation (#7) #16

Workflow file for this run

name: Code analysis
on:
push:
branches:
- develop
pull_request:
branches-ignore:
- master
workflow_dispatch:
jobs:
format-and-lint:
name: Format code
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache SBT
uses: actions/cache@v3
with:
path: |
~/.ivy2/cache
~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
- name: Setup JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
- name: Setup Scala and SBT
uses: olafurpg/setup-scala@v14
with:
java-version: '8'
- name: Check and format code with Scalafmt
run: sbt scalafmtAll
- name: Check and fix code with Scalafix
run: sbt scalafixAll
- name: Check for changes and commit
id: git-check
run: |
if [ -n "$(git status --porcelain | grep -v '^??')" ]; then
echo "changes=true" >> $GITHUB_ENV # Use environment file to set output
git config --global user.name 'GitHub Actions Bot'
git config --global user.email '[email protected]'
git add -u
git commit -m "Apply code quality checks (auto-formatted)"
git fetch --prune
git pull --rebase origin ${{ github.head_ref }}
git push origin HEAD:${{ github.head_ref }}
else
echo "No changes to commit."
fi
env:
CI: true
- name: Post retry comment
if: env.changes == 'true'
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request ? context.payload.pull_request.number : null;
if (prNumber) {
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
const newBody = pr.body + '\n\nAuto-commit applied. A retry was triggered due to a failure in formatting/linting checks.';
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
body: newBody
});
} else {
console.log('No pull request context found, unable to update PR description.');
}