Skip to content

Commit

Permalink
feat(ci): CI for automatic backend formatting on request (#2338)
Browse files Browse the repository at this point in the history
* CI for automatic backend formatting on request

* intentionally misformat some code

* Automated backend code formatting

---------

Co-authored-by: Loculus bot <bot@loculus.org>
  • Loading branch information
theosanderson and Loculus bot authored Jul 25, 2024
1 parent a0ea3b9 commit 945c801
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/format-backend-on-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Format Backend Code
on:
workflow_dispatch:
pull_request:
types: [synchronize, labeled]
paths:
- "backend/**"
jobs:
format:
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'format_me'))
permissions:
contents: write
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "adopt"

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Format Backend Code
run: ./gradlew ktlintFormat
working-directory: ./backend

- name: Commit and Push Changes
run: |
git config --global user.name 'Loculus bot'
git config --global user.email 'bot@loculus.org'
git add -A
git commit -m "Automated backend code formatting" || echo "No changes to commit"
git push origin HEAD:${{ github.head_ref }}

0 comments on commit 945c801

Please sign in to comment.