From 9b9948b9bac95e501cf0fd15366a329ad108b201 Mon Sep 17 00:00:00 2001 From: Nicholas Chiang Date: Wed, 6 Apr 2022 23:11:28 -0700 Subject: [PATCH] ci(github/workflows): add publish action --- .github/workflows/publish.yml | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..28ea27d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,45 @@ +name: 🚀 Publish +on: + push: + branches: + - master + pull_request: {} + +jobs: + test: + name: ⚡ Test + runs-on: ubuntu-latest + steps: + - name: 🛑 Cancel previous runs + uses: styfle/cancel-workflow-action@0.9.1 + + - name: ⬇️ Checkout repo + uses: actions/checkout@v3 + + - name: ⎔ Setup node + uses: actions/setup-node@v3 + with: + node-version: 16 + + - name: 📥 Download deps + uses: bahmutov/npm-install@v1 + + - name: ⚡ Run tests + run: npm run test + + publish: + name: 🚀 Publish + runs-on: ubuntu-latest + needs: [test] + if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }} + steps: + - name: 🛑 Cancel previous runs + uses: styfle/cancel-workflow-action@0.9.1 + + - name: ⬇️ Checkout repo + uses: actions/checkout@v3 + + - name: 🚀 Publish package + uses: JS-DevTools/npm-publish@v1 + with: + token: ${{ secrets.NPM_TOKEN }}