obs to jobs fix #2
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: deploy to development | |
on: | |
push: | |
branches: | |
- trunk | |
tags: | |
- '*' | |
jobs: | |
generate-and-upload-static-files: | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
id-token: write | |
contents: read | |
concurrency: | |
group: enroll-fe2 | |
cancel-in-progress: false | |
outputs: | |
SHORT_SHA: ${{ steps.setvars.outputs.SHORT_SHA }} | |
REPO_NAME: ${{ steps.setvars.outputs.REPO_NAME }} | |
MY_ENV: ${{ steps.setvars.outputs.MY_ENV }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set Vars | |
id: setvars | |
run: | | |
export SHORT_SHA=$(echo $GITHUB_SHA | head -c7) | |
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_ENV | |
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_OUTPUT | |
export REPO_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}') | |
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_ENV | |
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_OUTPUT | |
# figure out which ENV we should deploy for | |
if [ "${GITHUB_REF_TYPE}" = "tag" ] | |
then | |
export MY_ENV='prod' | |
else | |
export MY_ENV='dev' | |
fi | |
echo "MY_ENV=${MY_ENV}" >> $GITHUB_ENV | |
echo "MY_ENV=${MY_ENV}" >> $GITHUB_OUTPUT | |
if [ "${MY_ENV}" = "prod" ] | |
then | |
S3_BUCKET='' | |
CLOUDFRONT_DIST_ID='' | |
BASE_URL='' | |
else | |
S3_BUCKET='dev-shop-tax-credit-tool-cme-openhbx-org-2' | |
CLOUDFRONT_DIST_ID='E193HLDEQL7I0G' | |
BASE_URL='https://dev-shop-tax-credit-tool.cme.openhbx.org/' | |
fi | |
echo "S3_BUCKET=${S3_BUCKET}" >> $GITHUB_ENV | |
echo "CLOUDFRONT_DIST_ID=${CLOUDFRONT_DIST_ID}" >> $GITHUB_ENV | |
echo "BASE_URL=${BASE_URL}" >> $GITHUB_ENV | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.ME_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.ME_AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Cache Node Modules | |
id: cache-nodemodules | |
uses: actions/cache@v4 | |
with: | |
key: enroll-fe2-npm-${{ hashFiles('package-lock.json') }} | |
path: | | |
node_modules | |
- name: Install | |
if: steps.cache-nodemodules.outputs.cache-hit != 'true' | |
npm install | |
- name: Build | |
run: | | |
nx build sbtcc | |
- name: Deploy Static Files to S3 | |
run: | | |
cd dist/apps/sbtcc | |
aws s3 sync --acl public-read . s3://${{ env.S3_BUCKET }}/ --delete | |
- name: Invalidate Current Files on CloudFront & Wait | |
run: | | |
invalidationId=`aws cloudfront create-invalidation --distribution-id ${{ env.CLOUDFRONT_DIST_ID }} --output text --query 'Invalidation.Id' --paths '/*'` | |
# disable if wanting to save minutes | |
aws cloudfront wait invalidation-completed --distribution-id ${{ env.CLOUDFRONT_DIST_ID }} --id ${invalidationId} | |
- name: Load up CDN Cache | |
run: | | |
for i in {1..25} | |
do | |
curl "${{ env.BASE_URL }}" |