Skip to content

Commit

Permalink
ci: dont publish to NPM if the release fails
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AdeAttwood committed Feb 4, 2023
1 parent bf0898e commit 2fd1c99
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

1 comment on commit 2fd1c99

@vercel
Copy link

@vercel vercel bot commented on 2fd1c99 Feb 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

react-form – ./

react-form-git-0x-adeattwood.vercel.app
react-form-sandy.vercel.app
react-form-adeattwood.vercel.app

Please sign in to comment.