Merge pull request #25 from miztch/add-events-vct-2024 #34
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
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- ".github/workflows/*" | |
- "**.svg" | |
- "**.md" | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install jq | |
uses: dcarbone/[email protected] | |
- name: Setup Python | |
uses: actions/setup-python@v3 | |
- name: Setup AWS SAM CLI | |
uses: aws-actions/setup-sam@v2 | |
- name: Setup AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1-node16 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Setup Google service account key file | |
env: | |
GOOGLE_SERVICE_ACCOUNT_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} | |
run: | | |
# base64 decode key and write out to the file | |
echo $GOOGLE_SERVICE_ACCOUNT_KEY | base64 -d > function/add-gcal-event/service_account_key.json | |
- name: Prepare SAM parameters | |
env: | |
API_ENDPOINT_DOMAIN_NAME: ${{ secrets.API_ENDPOINT_DOMAIN_NAME }} | |
GOOGLE_SERVICE_ACCOUNT_ID: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_ID }} | |
GCAL_ID_APAC: ${{ vars.GCAL_ID_APAC }} | |
GCAL_ID_BR_LATAM: ${{ vars.GCAL_ID_BR_LATAM }} | |
GCAL_ID_EAST_ASIA: ${{ vars.GCAL_ID_EAST_ASIA }} | |
GCAL_ID_EMEA: ${{ vars.GCAL_ID_EMEA }} | |
GCAL_ID_NA: ${{ vars.GCAL_ID_NA }} | |
GCAL_ID_INTERNATIONAL: ${{ vars.GCAL_ID_INTERNATIONAL }} | |
SCHEDULE_EXPRESSION: ${{ vars.SCHEDULE_EXPRESSION }} | |
DAYS_TO_GET: ${{ vars.DAYS_TO_GET }} | |
DAYS_TO_RETAIN_LOGS: ${{ vars.DAYS_TO_RETAIN_LOGS }} | |
run: | | |
tee params.json << EOF | |
{ | |
"APIEndpointDomainName": "${API_ENDPOINT_DOMAIN_NAME}", | |
"GoogleServiceAccountId": "${GOOGLE_SERVICE_ACCOUNT_ID}", | |
"CalendarIdApac": "${GCAL_ID_APAC}", | |
"CalendarIdBrLatam": "${GCAL_ID_BR_LATAM}", | |
"CalendarIdEastAsia": "${GCAL_ID_EAST_ASIA}", | |
"CalendarIdEmea": "${GCAL_ID_EMEA}", | |
"CalendarIdNa": "${GCAL_ID_NA}", | |
"CalendarIdInternational": "${GCAL_ID_INTERNATIONAL}", | |
"ScheduleExpression": "${SCHEDULE_EXPRESSION}", | |
"DaysToGet": "${DAYS_TO_GET}", | |
"DaysToRetainLogs": "${DAYS_TO_RETAIN_LOGS}" | |
} | |
EOF | |
- name: Build SAM packages | |
run: sam build --use-container | |
- name: Deploy SAM application | |
env: | |
BUCKET_NAME: ${{ secrets.PROVISIONING_BUCKET_NAME }} | |
REGION: ${{ secrets.AWS_REGION }} | |
STACK_NAME: ${{ vars.STACK_NAME }} | |
run: | | |
sam deploy \ | |
--template-file .aws-sam/build/template.yaml \ | |
--stack-name $STACK_NAME \ | |
--s3-bucket $BUCKET_NAME \ | |
--s3-prefix $STACK_NAME \ | |
--capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND \ | |
--region $REGION \ | |
--force-upload \ | |
--no-confirm-changeset \ | |
--no-fail-on-empty-changeset \ | |
--parameter-overrides "$(jq -j 'to_entries[] | "\(.key)='\\\"'\(.value)'\\\"''\ '"' params.json)" |