Fix github actions for updating jakarta branch #34
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: Update jakarta branch | |
on: | |
push: | |
branches: | |
- integration | |
jobs: | |
checkout-and-build: | |
if: github.repository == 'veraPDF/veraPDF-pdfbox-validation' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
java-version: [11, 17, 21] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: integration | |
- name: JDK setup | |
uses: actions/setup-java@v4 | |
continue-on-error: true | |
with: | |
java-version: ${{ matrix.java-version }} | |
distribution: 'temurin' | |
cache: maven | |
- name: Fetch jakarta branch and checkout | |
run: | | |
git fetch origin jakarta:jakarta | |
git checkout -b test-branch jakarta | |
- name: Configure user name | |
run: | | |
git config user.name "Git User" | |
git config user.email "[email protected]" | |
- name: Add commit to the test branch | |
run: git cherry-pick -m 1 ${{ github.event.before }}..${{ github.event.after }} --empty=drop | |
- name: Build project with Maven | |
if: success() | |
run: mvn --batch-mode --update-snapshots verify | |
merge: | |
runs-on: ubuntu-latest | |
needs: checkout-and-build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: integration | |
- name: Generate new branch name | |
id: new-branch-name | |
run: echo "branch_name=new-branch-$(date +%s)" >> "$GITHUB_OUTPUT" | |
- name: Fetch jakarta branch and checkout | |
run: | | |
git fetch origin jakarta:jakarta | |
git checkout -b ${{ steps.new-branch-name.outputs.branch_name }} jakarta | |
- name: Configure user name | |
run: | | |
git config user.name "Git User" | |
git config user.email "[email protected]" | |
- name: Add commit to new branch | |
run: git cherry-pick -m 1 ${{ github.event.before }}..${{ github.event.after }} --empty=drop | |
- name: Merge branch into jakarta | |
if: success() | |
run: | | |
git push origin ${{ steps.new-branch-name.outputs.branch_name }} | |
git checkout jakarta | |
git merge ${{ steps.new-branch-name.outputs.branch_name }} | |
git push origin jakarta | |
- name: Delete new branch | |
run: git push origin --delete ${{ steps.new-branch-name.outputs.branch_name }} | |
send-notification: | |
runs-on: ubuntu-latest | |
needs: [checkout-and-build, merge] | |
if: | | |
always() && | |
github.repository == 'veraPDF/veraPDF-pdfbox-validation' && | |
(contains(needs.*.result, 'failure') || | |
contains(needs.*.result, 'skipped') || | |
contains(needs.*.result, 'cancelled')) | |
steps: | |
- name: Send notification if build or merge failed | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }} | |
uses: voxmedia/github-action-slack-notify-build@v1 | |
with: | |
channel_id: C03E3JJGLQL | |
status: FAILED | |
color: danger |