Skip to content

Commit

Permalink
#426: implement Check last workflow status job (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvomiero authored Jul 4, 2024
1 parent 2571a16 commit bd17cb9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,27 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dmaven.install.skip=true -Dgpg.skip=true -Dstyle.color=always -B -ntp -P deploy deploy

check_status:
runs-on: ubuntu-latest
needs: verify_commit
if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'false' }}
steps:
- name: Check last workflow status
id: check_status
run: |
workflow_filename="nightly-build.yml"
last_workflow=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/$workflow_filename/runs?per_page=1" | jq -r '.workflow_runs[0]')
conclusion=$(echo $last_workflow | jq -r '.conclusion')
echo "conclusion=$conclusion" >> $GITHUB_ENV
- name: Print and handle the status
run: |
echo "The status of the last workflow run is: ${{ env.conclusion }}"
if [ "${{ env.conclusion }}" != "success" ]; then
echo "The last workflow did not succeed. Failing this workflow."
exit 1
else
echo "The last workflow succeeded. This workflow will succeed."
fi

0 comments on commit bd17cb9

Please sign in to comment.