From 2fd1c9987f9f32155fa6b4dfc493c1007397351c Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Sat, 4 Feb 2023 10:36:14 +0000 Subject: [PATCH] ci: dont publish to NPM if the release fails We are using the `workflow_run` action to publish a build to NPM when a release is complete. This is also running when the release workflow fails. Now we are using a conditional jobs to only publish the package if the release we successful. I have added an extra job to fail the publish if the release fails so we get the correct statuses and it dose not look like the publish passes because no jobs have run. Fixes Issue: #95 --- .github/workflows/publish-release.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index bca83b2..c9728e7 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -8,6 +8,7 @@ on: jobs: build: runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout uses: actions/checkout@v3 @@ -25,3 +26,10 @@ jobs: run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + fail: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - name: Fail + run: echo "The release must pass for this to run" && exit 1