As part of my #ActionsHackathon submission, I'll be sharing a workflow that will be automatically deploying versions of your NPM package using a project I developed called npm-package-deploy.
In a few words:
This project was originally developed because I had a project where I wanted to automate the NPM version releases on each commit to master in order to make it a bit easier and quicker.
Prerequisites (Before usage):
- Install the
npm-package-deployer
package. - Add a lint script to your package.json (
"lint": "eslint ."
) - Add a deploy script to your package.json (
"deploy": "npm-deploy [name of your package]"
) - Add a script for your tests (which I called
unit-tests
in my example) - Define a secret called
NPM_AUTH_TOKEN
which holds the value of your NPM authentication token. - Define secrets for
BOT_NAME
andBOT_EMAIL
that will hold any fake values. (Used to define GIT name and GIT email for the deployment)
My Workflow (Named -> Deployment BOT)
#This is an automatic deployer flow name: Deployment Bot on: push: branches: [ master ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Configurating GIT run: git config --global user.name $BOT_NAME && git config --global user.email $BOT_EMAIL env: BOT_NAME: ${{secrets.BOT_NAME}} BOT_EMAIL: ${{secrets.BOT_EMAIL}} - name: Creating .npmrc file run: echo "registry=https://registry.npmjs.org/" >> ~/.npmrc && echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> ~/.npmrc env: NPM_AUTH_TOKEN: ${{secrets.NPM_AUTH}} - name: Installing NPM packages run: npm install - name: Running tests run: npm run unit-tests - name: Verifying linting run: npm run lint - name: Deploying version run: npm run build && npm run deploy
Submission Category:
Maintainer Must-Haves
Yaml File or Link to Code:
Additional Resources / Info
Link to the using repository
Link to a GitHub Action Execution
Top comments (0)