Run Build, tests and Publish (workflow_dispatch) #130
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: Run Build, tests and Publish (workflow_dispatch) | |
on: | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: | | |
The branch, tag or SHA to checkout. When checking out the repository that | |
triggered a workflow, this defaults to the reference or SHA for that event. | |
Otherwise, uses the default branch. | |
required: false | |
default: master | |
pull_request: | |
paths-ignore: | |
- .helm/** | |
push: | |
paths-ignore: | |
- .helm/** | |
branches-ignore: | |
- gh-pages | |
env: | |
NODE_ENV: test | |
jobs: | |
test_workflow: | |
runs-on: ubuntu-latest | |
name: Run Build, Lint and Tests | |
steps: | |
# Checkout the repository | |
- uses: actions/checkout@v3 | |
# Setup the node environment | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
# Cache dependencies | |
- uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
# Install dependencies | |
- run: npm ci --prefer-offline | |
# Build application | |
- run: npm run build | |
# Run lint | |
- run: npm run lint | |
# Run unit tests | |
- run: npm run test | |
# Run functional tests with coverage | |
- run: npm run test:e2e:cov | |
deploy: | |
runs-on: ubuntu-latest | |
name: Deploy the docker image to GCP | |
needs: test_workflow | |
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'workflow_dispatch' }} | |
steps: | |
# Checkout the repository | |
- uses: actions/checkout@v3 | |
# Setup the node environment | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
# Set up google credentials | |
- uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GCP_PUBLIC_SA }} | |
# Configure Docker to use the gcloud command-line tool as a credential | |
# helper for authentication | |
- run: gcloud auth configure-docker europe-docker.pkg.dev | |
- run: npm install | |
- run: npx semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_GHA_PAT }} |