Skip to content

Label API Snapshot. #3420

Label API Snapshot.

Label API Snapshot. #3420

# To debug, it's recommended you modify / use the version in the test-actions repo:
# https://github.com/act-now-coalition/test-actions/blob/master/.github/workflows/label_api_snapshot.yml
# Used to assign a label (like /snapshot/latest or /v0) to a published API
# snapshot (like /snapshot/123).
#
name: Label API Snapshot.
on:
workflow_dispatch:
inputs:
snapshot_id:
description: 'The snapshot ID (e.g. 1234) to be labeled as "latest" and used by the API.'
required: true
jobs:
label-api-snapshot:
runs-on: ubuntu-latest
env:
AWS_S3_BUCKET: 'data.covidactnow.org'
LABEL: 'latest'
SNAPSHOT_ID: '${{ github.event.inputs.snapshot_id }}'
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Verify Snapshot ID provided
if: ${{ !env.SNAPSHOT_ID }}
run: 'echo "Missing input parameter: snapshot_id" ; exit 1'
# TODO: We want to replace this with a "symlink" of some kind, perhaps implemented at
# the CloudFront layer.
- name: Create Label (Copy files from /snapshot/${{env.SNAPSHOT_ID}}/ to /${{env.LABEL}}/)
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: 's3://${{env.AWS_S3_BUCKET}}/snapshot/${{env.SNAPSHOT_ID}}/'
DEST_DIR: '${{env.LABEL}}/'
- name: API Cloudfront Distribution Cache Invalidation
uses: awact/cloudfront-action@master
env:
SOURCE_PATH: '/*'
AWS_REGION: 'us-east-1'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DISTRIBUTION_ID: ${{ secrets.API_CLOUDFRONT_DISTRIBUTION_ID }}
- name: Slack notification
if: always() # Pick up events even if the job fails or is canceled.
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_DAILY_DEPLOYS }}
STATUS: ${{job.status}}
uses: Ilshidur/action-slack@fb92a78a305a399cd6d8ede99d641f2b9224daf3
with:
args: 'Action to label {{SNAPSHOT_ID}} as {{LABEL}}. Job status: {{STATUS}}'