fix: Some random code for sanity checking #27
Workflow file for this run
This file contains 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
name: Pull Requests | |
on: | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build-pr: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- uses: webiny/[email protected] | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "21" | |
distribution: "temurin" | |
cache: maven | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
# with: | |
# cache: npm | |
- name: Run OpenRewrite # TODO : open pr with all changes | |
run: ./mvnw rewrite:run -P pr | |
- name: Run Spotless # TODO : open pr with all changes | |
run: ./mvnw spotless:apply -P pr | |
- name: Push local changes if necessary | |
run: | | |
[[ -z $(git status -s) ]] && WAS_DIRTY=false | |
[[ -n $(git status -s) ]] && WAS_DIRTY=true | |
echo "WAS_DIRTY=$WAS_DIRTY" >> "$GITHUB_ENV" | |
[[ $WAS_DIRTY = false ]] && exit 0 | |
git config --global user.name "github-actions" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git switch -c linting/${{ github.head_ref }} | |
git add -A | |
git commit -m "style: Apply linting rules" | |
git push "https://${GITHUB_ACTOR}:${{ env.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" HEAD:refs/heads/linting/${{ github.head_ref }} --force | |
set +e | |
gh pr create -B ${{ github.head_ref }} -H linting/${{ github.head_ref }} -b 'Adds required linting changes' -a ${{ github.event.pull_request.user.login }} -t 'Apply linting rules and refactorings for ${{ github.head_ref }}' | |
set -e | |
shell: bash | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Did linting pass? | |
run: "[[ $WAS_DIRTY = true ]] && exit 1" | |
- name: Build with Maven | |
run: ./mvnw -B package -Drevision='${{ steps.increment-version.outputs.new-version }}' -Dchangelist='-SNAPSHOT' --file pom.xml -P pr |