build: refactor container build process #2824
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: screenshot | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
jobs: | |
screenshot: | |
runs-on: ubuntu-latest | |
# Taking screenshots requires direct access to imagery inside of s3://linz-basemaps | |
# which no other repository should have and github secret access is locked down | |
# | |
# As the workflow can be run from either a push or a pull request, it needs to check that | |
# 1. the push is directly to linz/basemaps | |
# 2. pull request originated from 'linz/basemaps' | |
if: | | |
(github.event_name == 'push' && github.repository == 'linz/basemaps') || | |
(github.event.pull_request.head.repo.full_name == 'linz/basemaps') | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: linz/action-typescript@v3 | |
# Package all the files | |
- name: Bundle & Package all files | |
run: | | |
npx lerna run bundle --stream | |
npm pack --workspaces | |
env: | |
NODE_ENV: 'production' | |
- name: (NonProd) Configure AWS Credentials | |
uses: aws-actions/[email protected] | |
with: | |
aws-region: ap-southeast-2 | |
mask-aws-account-id: true | |
role-to-assume: ${{ secrets.AWS_ROLE_SCREENSHOT }} | |
- name: (Screenshot) Screenshot Pull Request Changes | |
run: | | |
./packages/cli/bin/bmc.js serve --config s3://linz-basemaps/config/config-latest.json.gz & | |
# Wait for the server to start | |
timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:5000/v1/version)" != "200" ]]; do sleep 0.5; done' || false | |
docker run --rm --network="host" -v $PWD:$PWD ghcr.io/linz/basemaps-screenshot/cli:v1 --url http://localhost:5000 --output $PWD/.artifacts/visual-snapshots | |
- name: Save snapshots | |
uses: blacha/action-visual-snapshot@v2-next | |
with: | |
save-only: true | |
snapshot-path: .artifacts/visual-snapshots | |
visual-diff: | |
permissions: | |
id-token: write | |
contents: write | |
checks: write | |
needs: [screenshot] | |
name: validate screenshots | |
if: github.ref != 'refs/heads/master' && github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
- name: AWS Configure | |
uses: aws-actions/[email protected] | |
with: | |
aws-region: ap-southeast-2 | |
mask-aws-account-id: true | |
role-to-assume: ${{ secrets.AWS_ROLE_SCREENSHOT }} | |
- name: Diff snapshots | |
id: visual-snapshots-diff | |
uses: blacha/action-visual-snapshot@v2-next | |
with: | |
storage-prefix: 's3://linz-basemaps-screenshot' | |
storage-url: 'https://d25mfjh9syaxsr.cloudfront.net' |