Skip to content

1.23.4

1.23.4 #231

Workflow file for this run

name: Release
on:
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v2.1.3
branches:
- development
jobs:
set_environment:
runs-on: ubuntu-latest
steps:
- name: Set up environment based on branch
id: environment_check
shell: bash
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
BRANCH_NAME=${BRANCH_NAME#refs/tags/}
ENVIRONMENT="development"
if [[ "$BRANCH_NAME" == v* ]]; then
ENVIRONMENT="production"
fi
echo "environment=${ENVIRONMENT,,}" >> $GITHUB_OUTPUT
outputs:
environment: ${{ steps.environment_check.outputs.environment }}
update_database:
if: needs.set_environment.outputs.environment == 'production'
runs-on: ubuntu-latest
needs: set_environment
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js 16
uses: actions/setup-node@v4
with:
node-version: "16"
- name: Install NPM Dependencies
run: npm install --include=dev
# Sync content to production DB
- name: Sync content to Prod Instance
env:
NEO4J_HOST: ${{ secrets.PROD_NEO4J_HOST }}
NEO4J_USERNAME: ${{ secrets.PROD_NEO4J_USERNAME }}
NEO4J_PASSWORD: ${{ secrets.PROD_NEO4J_PASSWORD }}
run: npm run sync:db
# Test the database
- name: Test Database
env:
NEO4J_HOST: ${{ secrets.PROD_NEO4J_HOST }}
NEO4J_USERNAME: ${{ secrets.PROD_NEO4J_USERNAME }}
NEO4J_PASSWORD: ${{ secrets.PROD_NEO4J_PASSWORD }}
run: npm run test:db
sync_assets:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
needs: [set_environment]
environment: ${{ needs.set_environment.outputs.environment }}
env:
ENVIRONMENT: ${{ needs.set_environment.outputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_DEPLOY_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
# Sync images to CDN
- name: Sync public/ to S3
if: env.ENVIRONMENT == 'production'
run: aws s3 sync ./public s3://${{ vars.ASSETS_BUCKET_NAME }}/assets --acl public-read
upload_zip:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
needs: [set_environment, sync_assets]
environment: ${{ needs.set_environment.outputs.environment }}
env:
ENVIRONMENT: ${{ needs.set_environment.outputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_DEPLOY_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
- name: Create course asciidoc zip
run: npm run build:content
- name: Upload courses to S3
run: |
aws s3 cp ./courses.zip "s3://${{ vars.CERTS_COURSES_BUCKET_NAME }}/content/courses.zip"
- name: Install NPM Dependencies
run: npm install --include=dev
- name: Create HTML zip
run: npm run build:html
- name: Upload HTML to S3
run: |
aws s3 cp ./html.zip "s3://${{ vars.CERTS_COURSES_BUCKET_NAME }}/content/html.zip"
restart-cluster:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
needs: [set_environment, sync_assets, upload_zip]
environment: ${{ needs.set_environment.outputs.environment }}
env:
ENVIRONMENT: ${{ needs.set_environment.outputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_DEPLOY_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
- name: Deploying services with an env file
uses: brunocascio/ecs-deploy@v2.2.0
env:
CLUSTER_NAME: ${{ env.ENVIRONMENT }}-graphacademy-cluster
SERVICE_NAME: ${{ env.ENVIRONMENT }}-graphacademy-service
with:
args: deploy ${{ env.CLUSTER_NAME }} ${{ env.SERVICE_NAME }} --timeout -1
invalidate_cache:
runs-on: ubuntu-latest
needs: [set_environment, sync_assets, upload_zip]
environment: ${{ needs.set_environment.outputs.environment }}
env:
ENVIRONMENT: ${{ needs.set_environment.outputs.environment }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_DEPLOY_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
- name: Invalidate CloudFront Cache
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ vars.CDN_DISTRIBUTION_ID }}
PATHS: "/*"
AWS_REGION: ${{ vars.AWS_REGION }}