feat(vector): Update the topographic map vector data. #2255
Workflow file for this run
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: build | |
on: | |
workflow_call: | |
pull_request: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
permissions: | |
id-token: write | |
contents: read | |
issues: write # This permission shouldn't needed as there is a bug currently for gh pr edit. https://github.com/cli/cli/issues/4631 | |
pull-requests: write | |
outputs: | |
config_path: ${{ steps.path.outputs.config_path }} | |
runs-on: ubuntu-latest | |
concurrency: deploy-${{ github.head_ref }} | |
env: | |
BASEMAPS_BUCKET: linz-basemaps | |
BASEMAPS_STAGING_BUCKET: linz-basemaps-staging | |
BASEMAPS_CONTAINER: ghcr.io/linz/basemaps/cli:v6.39.0-39-gdbedf1b1 | |
SCREENSHOT_CONTAINER: ghcr.io/linz/basemaps-screenshot/cli:v1 | |
DOCKER_AWS_ENV: -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_REGION -e AWS_DEFAULT_REGION | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_NUMBER: ${{ github.event.number }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: linz/action-typescript@v2 | |
- name: (Build) Prepare path for glyphs and sprites | |
run: | | |
mkdir -p assets/fonts/ | |
mkdir -p assets/sprites/ | |
- name: (Build) Build Glyphs | |
uses: linz/action-build-pbf-glyphs@v1 | |
with: | |
source: config/fonts/ | |
target: assets/fonts/ | |
- name: (Build) Build Sprites | |
run: | | |
docker run -v $PWD:$PWD ${DOCKER_AWS_ENV} ${BASEMAPS_CONTAINER} sprites --path $PWD/config/sprites/topographic/ --output $PWD/assets/sprites/ | |
- name: (Build) Bundle Assets Into Cotar | |
run: | | |
docker run -v $PWD:$PWD ${DOCKER_AWS_ENV} ${BASEMAPS_CONTAINER} bundle-assets --assets $PWD/assets/ --output $PWD/assets.tar.co | |
ASSETS_HASH=$(ls assets*.tar.co) | |
echo "ASSETS_HASH=${ASSETS_HASH}" >> $GITHUB_ENV | |
echo "ASSETS_LOCATION_STAGING=s3://${BASEMAPS_STAGING_BUCKET}/assets/${ASSETS_HASH}" >> $GITHUB_ENV | |
echo "ASSETS_LOCATION=s3://${BASEMAPS_BUCKET}/assets/${ASSETS_HASH}" >> $GITHUB_ENV | |
- name: (Build) 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: (NonProd) Bundle Config File | |
run: | | |
docker run -v $PWD:$PWD ${DOCKER_AWS_ENV} ${BASEMAPS_CONTAINER} bundle --config $PWD/config --output $PWD/config-staging.json --assets ${ASSETS_LOCATION_STAGING} | |
CONFIG_HASH_STAGING=$(cat config-staging.json | jq .hash -r) | |
echo "CONFIG_LOCATION_STAGING=s3://${BASEMAPS_STAGING_BUCKET}/config/config-${CONFIG_HASH_STAGING}.json.gz" >> $GITHUB_ENV | |
- name: (NonProd) Upload Hashed Assets | |
run: | | |
aws s3 cp ${ASSETS_HASH} ${ASSETS_LOCATION_STAGING} | |
- name: (NonProd) Upload Hashed Config File | |
run: | | |
gzip -9 -k config-staging.json | |
aws s3 cp config-staging.json.gz ${CONFIG_LOCATION_STAGING} --content-encoding gzip | |
- id: path | |
name: Define Outputs for Screenshots | |
run: | | |
echo "config_path=${CONFIG_LOCATION_STAGING}" >> "$GITHUB_OUTPUT" | |
- name: (NonProd) AWS Configure | |
uses: aws-actions/[email protected] | |
with: | |
aws-region: ap-southeast-2 | |
mask-aws-account-id: true | |
role-to-assume: ${{ secrets.AWS_ROLE_NON_PROD }} | |
- name: (NonProd - Config) Compare To DynamoDB | |
run: | | |
docker run -v $PWD:$PWD ${DOCKER_AWS_ENV} ${BASEMAPS_CONTAINER} import --config ${CONFIG_LOCATION_STAGING} --output $PWD/changes.md | |
- name: (NonProd - Config) Import Config To DynamoDB | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
run: | | |
docker run -v $PWD:$PWD ${DOCKER_AWS_ENV} ${BASEMAPS_CONTAINER} import --config ${CONFIG_LOCATION_STAGING} --commit | |
- name: (Prod) AWS Configure | |
uses: aws-actions/[email protected] | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
with: | |
aws-region: ap-southeast-2 | |
mask-aws-account-id: true | |
role-to-assume: ${{ secrets.AWS_ROLE_PROD }} | |
- name: (Prod) Bundle Config File | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
run: | | |
docker run -v $PWD:$PWD ${DOCKER_AWS_ENV} ${BASEMAPS_CONTAINER} bundle --config $PWD/config --output $PWD/config.json --assets ${ASSETS_LOCATION} | |
CONFIG_HASH=$(cat config.json | jq .hash -r) | |
echo "CONFIG_LOCATION=s3://${BASEMAPS_BUCKET}/config/config-${CONFIG_HASH}.json.gz" >> $GITHUB_ENV | |
- name: (Prod - Config) Upload Hashed Assets | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
run: | | |
aws s3 cp ${ASSETS_HASH} ${ASSETS_LOCATION} | |
- name: (Prod - Config) Upload Hashed Config File | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
run: | | |
gzip -9 -k config.json | |
aws s3 cp config.json.gz ${CONFIG_LOCATION} --content-encoding gzip | |
- name: (Prod - Config) Upload Latest Config File | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
run: | | |
aws s3 cp config.json.gz s3://${BASEMAPS_BUCKET}/config/config-latest.json.gz --content-encoding gzip | |
- name: (Prod - Config) Compare to DynamoDB | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
run: | | |
docker run -v $PWD:$PWD ${DOCKER_AWS_ENV} ${BASEMAPS_CONTAINER} import --config ${CONFIG_LOCATION} --output $PWD/changes.md | |
- name: (Prod - Config) Import Config To DynamoDB | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
run: | | |
docker run -v $PWD:$PWD ${DOCKER_AWS_ENV} ${BASEMAPS_CONTAINER} import --config ${CONFIG_LOCATION} --commit | |
- name: Update Description | |
if: github.ref != 'refs/heads/master' && github.event_name == 'pull_request' | |
run: | | |
[ ! -f changes.md ] || gh pr comment ${PR_NUMBER} --body-file changes.md | |
screenshot: | |
permissions: | |
id-token: write | |
contents: read | |
needs: [build] | |
name: taking screenshots | |
runs-on: ubuntu-latest | |
env: | |
BASEMAPS_CONTAINER: ghcr.io/linz/basemaps/cli:v6.39.0-39-gdbedf1b1 | |
SCREENSHOT_CONTAINER: ghcr.io/linz/basemaps-screenshot/cli:v1 | |
DOCKER_AWS_ENV: -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_REGION -e AWS_DEFAULT_REGION | |
CONFIG_PATH: ${{needs.build.outputs.config_path}} | |
steps: | |
- name: (Screenshot) 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: (Screenshot) Screenshot Pull Request Changes | |
run: | | |
docker run -p 5000:5000 -v $PWD:$PWD ${DOCKER_AWS_ENV} ${BASEMAPS_CONTAINER} serve --config ${CONFIG_PATH} & | |
# 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 ${DOCKER_AWS_ENV} ${SCREENSHOT_CONTAINER} --url http://localhost:5000 --output $PWD/.artifacts/visual-snapshots | |
- name: Save snapshots | |
uses: getsentry/action-visual-snapshot@v2 | |
with: | |
save-only: true | |
snapshot-path: .artifacts/visual-snapshots | |
visual-diff: | |
permissions: | |
id-token: write | |
contents: write | |
checks: write | |
needs: [build, 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 | |
with: | |
storage-prefix: "s3://linz-basemaps-screenshot" | |
storage-url: "https://d25mfjh9syaxsr.cloudfront.net" |