Post code suggestions on PRs with format issues #1
Workflow file for this run
This file contains hidden or 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
# Description: This workflow applies the formatter against the opened pull request and upload the patch. | |
# Since this pull request receives untrusted code, we should **NOT** have any secrets in the environment. | |
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | |
--- | |
name: pr-format-workflow | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
branches: | |
- main | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.ref }}' | |
cancel-in-progress: true | |
jobs: | |
upload-patch: | |
runs-on: ubuntu-latest | |
if: ${{ github.repository == 'spring-projects/spring-security' }} | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{github.event.pull_request.head.ref}} | |
repository: ${{github.event.pull_request.head.repo.full_name}} | |
- name: Set up gradle | |
uses: spring-io/spring-gradle-build-action@v2 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# Capture the PR number | |
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow | |
- name: Create pr_number.txt | |
run: echo "${{ github.event.number }}" > pr_number.txt | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: pr_number | |
path: pr_number.txt | |
- name: Remove pr_number.txt | |
run: rm -f pr_number.txt | |
# Format code | |
- name: Format with Gradle | |
run: ./gradlew format | |
# Capture the diff | |
- name: Create patch | |
run: | | |
git diff | tee git-diff.patch | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: patch | |
path: git-diff.patch |