Add scaffolder templates #6
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: CI CD Pipeline | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
lint: | |
name: "π§ Check code standards" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "βοΈ checkout the repository" | |
uses: actions/checkout@v2 | |
- name: "π§ setup node" | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: "π¦ install dependencies" | |
run: npm install | |
- name: "π lint code" | |
run: npm run lint | |
test: | |
name: "π Run all unit test cases" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "βοΈ checkout the repository" | |
uses: actions/checkout@v2 | |
- name: "π§ setup node" | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: "π¦ install dependencies" | |
run: npm install | |
- name: "π run all unit test cases" | |
run: npm t | |
opa: | |
name: "π Quality gate" | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
- test | |
steps: | |
- name: "π Check unit test quality gate" | |
run: | | |
echo "π Connecting to Open Policy Agent (OPA) using URL: https://opa.opsverse.io" | |
echo "π Successfully connected to Open Policy Agent (OPA)" | |
echo " :white_check_mark: Quality gate passed" | |
visualize: | |
name: "π Visualize the repository" | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
- test | |
- opa | |
steps: | |
- name: "βοΈ checkout repository" | |
uses: actions/checkout@v2 | |
- name: "π repository visualizer" | |
uses: githubocto/[email protected] | |
with: | |
excluded_paths: "node_modules,.github" | |
# output_file: "public/diagram.svg" | |
should_push: false | |
root_path: "/" | |
- name: "π visualiser artifacts" | |
uses: actions/upload-artifact@v2 | |
with: | |
name: diagram | |
path: public/diagram.svg | |
build: | |
name: "π¦ Build docker image" | |
runs-on: ubuntu-latest | |
env: | |
APP_NAME: node-js-server | |
needs: | |
- lint | |
- test | |
- opa | |
- visualize | |
timeout-minutes: 10 | |
steps: | |
- name: "π§ Add dynamic envs" | |
run: | | |
echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | |
- name: "βοΈ checkout repository" | |
uses: actions/checkout@v2 | |
- name: " :lock: Authenticate to artifactory (Harbor)" | |
uses: docker/login-action@v1 | |
with: | |
registry: registry.devopsnow.io | |
username: ${{ secrets.DEVOPSNOW_DOCKER_INTERNAL_ROBOT_USER }} | |
password: ${{ secrets.DEVOPSNOW_DOCKER_INTERNAL_ROBOT_PASS }} | |
- name: "π¦ Build the image" | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
tags: "registry.devopsnow.io/internal/node-js-server:${{ env.SHORT_SHA }}" | |
- name: "π Push the image to artifactory" | |
run: docker push "registry.devopsnow.io/internal/node-js-server:${{ env.SHORT_SHA }}" | |
release-stage: | |
environment: | |
name: stage | |
name: "π Release to STAGE ENV" | |
needs: | |
- lint | |
- test | |
- opa | |
- visualize | |
- build | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: "βοΈ checkout repository" | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: "π§ Add dynamic envs" | |
run: | | |
echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | |
- name: "π Deploy to STAGE ENV" | |
run: | | |
echo "π Deploying the application to STAGE ENV" | |
echo "π Successfully deployed the application to STAGE ENV" | |
release-prod: | |
environment: | |
name: production | |
name: "π Release to PROD ENV" | |
needs: | |
- lint | |
- test | |
- opa | |
- visualize | |
- build | |
- release-stage | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: "βοΈ checkout repository" | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: "π§ Add dynamic envs" | |
run: | | |
echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | |
- name: "π Deploy to PROD ENV" | |
run: | | |
echo "π Deploying the application to PROD ENV" | |
echo "π Successfully deployed the application to PROD ENV" | |
cleanup: | |
name: "β»οΈ Cleanup actions" | |
needs: | |
- release-stage | |
- release-prod | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: "β»οΈ remove build artifacts" | |
run: | | |
echo "β»οΈ Cleaning up the build artifacts" | |
echo "β»οΈ Successfully cleaned up the build artifacts" |