PA-19353: Migrate to Github action #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: password-strength | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- '*' | |
tags: | |
- '*' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
WEBCLIENTNAME: 'password-strength' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
WEBCLIENTNAME: ${{ env.WEBCLIENTNAME }} | |
strategy: | |
matrix: | |
node_version: [16] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Set up NodeJS | |
uses: actions/setup-node@v3 | |
with: | |
always-auth: true | |
node-version: ${{ matrix.node_version }} | |
- name: Set up NPM authentication | |
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > ~/.npmrc | |
- name: Install dependencies | |
run: CI=true npm ci | |
- name: Test | |
run: CI=true npm run test | |
- name: Build | |
run: CI=true npm run build | |
- name: NPM publish | |
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }} | |
run: CI=true npm publish | |
slack-notification: | |
needs: [build] | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Run Slack Notification | |
uses: actano/slack-action@master | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} | |
SLACK_CHANNEL: "a-team-ci" | |
GITHUB_TOKEN: ${{ secrets.ACTANO_GITHUB_TOKEN }} | |
GITHUB_RUN_ID: ${{ github.run_id }} | |
REPO_OWNER: ${{ github.repository_owner }} | |
REPO_NAME: ${{ github.event.repository.name }} | |
RUN_ID: ${{ github.run_id }} | |
SEND_SUCCESS_MESSAGE: "true" |