Skip to content

Deploy Web

Deploy Web #44

Workflow file for this run

name: Build and Deploy Web Image
on:
# PR targeting master is created or new commits are pushed
push:
branches:
- master
paths:
- "web/**"
# Manual trigger via GH Actions UI
workflow_dispatch:
env:
WORKING_DIRECTORY: ./web
IMAGE_NAME: jasper-web
GITHUB_IMAGE_REPO: ghcr.io/bcgov/jasper/
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
working-directory: ${{env.WORKING_DIRECTORY}}
# Lint errors exists from SCC and will be worked on separately.
- run: npm run lint
working-directory: ${{env.WORKING_DIRECTORY}}
continue-on-error: true
- run: npm run build
working-directory: ${{env.WORKING_DIRECTORY}}
# Unit test is not configured in SCC and will be worked on separately.
- run: npm run test --if-present
working-directory: ${{env.WORKING_DIRECTORY}}
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"
- name: Docker Build Image
working-directory: ${{env.WORKING_DIRECTORY}}/../
run: |
docker build --tag nginx-runtime -f docker/nginx-runtime/Dockerfile ./docker/nginx-runtime/
cd web
docker build --tag ss-web-artifacts -f Dockerfile.node . --build-arg WEB_BASE_HREF=/
cd ..
docker build --tag ${{ env.IMAGE_NAME }} -f docker/vue-on-nginx/Dockerfile ./docker/vue-on-nginx/
- name: Log in to the GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Push Image to GCHR
run: |
docker tag ${{ env.IMAGE_NAME }} ${{ env.GITHUB_IMAGE_REPO }}${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }}
output=$(docker push ${{ env.GITHUB_IMAGE_REPO }}${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }})
echo $output
digest=$(echo "$output" | grep "digest: sha256" | awk '{ print $3 }')
echo "::set-output name=digest::$digest"
deploy2dev:
needs: build
env:
ENVIRONMENT: dev
permissions:
packages: write
runs-on: ubuntu-latest
environment: dev
steps:
- name: Publish image to AWS ECR
run: /
echo ${{ needs.build.outputs.digest }}