Skip to content

Production Deploy

Production Deploy #82

Workflow file for this run

name: Production Deploy
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [release]
workflow_dispatch: # manual trigger
jobs:
# runs if CI workflow was successful OR if this was manually triggered
on-success:
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ref: release
- name: Set VERSION
run: echo "VERSION=$(./scripts/get_version.sh)" >> $GITHUB_ENV
- name: Heroku login
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: heroku container:login
- name: Release Backend on Heroku
uses: akhileshns/heroku-deploy@e86b991436e126ff9d78399b801a6610a64881c9
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: mitopen-production
heroku_email: ${{ secrets.HEROKU_EMAIL }}
branch: release
- name: Write commit SHA to file
run: echo $GITHUB_SHA > frontends/main/public/hash.txt
- name: Build and push the NextJS Docker image
env:
HEROKU_APP_NAME: mitopen-production-nextjs
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
ORIGIN: https://learn.mit.edu
MITOL_API_BASE_URL: https://api.learn.mit.edu
SITE_NAME: MIT Learn
SUPPORT_EMAIL: [email protected]
EMBEDLY_KEY: ${{ secrets.EMBEDLY_KEY_PROD }}
MITOL_AXIOS_WITH_CREDENTIALS: true
CSRF_COOKIE_NAME: ${{ secrets.CSRF_COOKIE_NAME_PROD }}
POSTHOG_API_HOST: https://app.posthog.com
POSTHOG_PROJECT_ID: ${{ secrets.POSTHOG_PROJECT_ID_PROD }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_PROJECT_API_KEY_PROD }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_PROD }}
SENTRY_ENV: ${{ secrets.MITOL_ENVIRONMENT_PROD }}
SENTRY_PROFILES_SAMPLE_RATE: ${{ secrets.SENTRY_PROFILES_SAMPLE_RATE_PROD }}
SENTRY_TRACES_SAMPLE_RATE: ${{ secrets.SENTRY_TRACES_SAMPLE_RATE_PROD }}
APPZI_URL: ${{ secrets.APPZI_URL_PROD }}
VERSION: ${{ github.sha }}
run: |
heroku container:push web \
--app $HEROKU_APP_NAME \
--recursive \
--arg NEXT_PUBLIC_ORIGIN=$ORIGIN,\
NEXT_PUBLIC_MITOL_API_BASE_URL=$MITOL_API_BASE_URL,\
NEXT_PUBLIC_SITE_NAME="$SITE_NAME",\
NEXT_PUBLIC_MITOL_SUPPORT_EMAIL=$SUPPORT_EMAIL,\
NEXT_PUBLIC_EMBEDLY_KEY=$EMBEDLY_KEY,\
NEXT_PUBLIC_MITOL_AXIOS_WITH_CREDENTIALS=$MITOL_AXIOS_WITH_CREDENTIALS,\
NEXT_PUBLIC_CSRF_COOKIE_NAME=$CSRF_COOKIE_NAME,\
NEXT_PUBLIC_POSTHOG_API_HOST=$POSTHOG_API_HOST,\
NEXT_PUBLIC_POSTHOG_PROJECT_ID=$POSTHOG_PROJECT_ID,\
NEXT_PUBLIC_POSTHOG_API_KEY=$POSTHOG_API_KEY,\
NEXT_PUBLIC_SENTRY_DSN=$SENTRY_DSN,\
NEXT_PUBLIC_SENTRY_ENV=$SENTRY_ENV,\
NEXT_PUBLIC_SENTRY_PROFILES_SAMPLE_RATE=$SENTRY_PROFILES_SAMPLE_RATE,\
NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE=$SENTRY_TRACES_SAMPLE_RATE,\
NEXT_PUBLIC_APPZI_URL=$APPZI_URL,\
NEXT_PUBLIC_VERSION=$VERSION \
--context-path .
- name: Release Frontend on Heroku
env:
HEROKU_APP_NAME: mitopen-production-nextjs
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: heroku container:release --app $HEROKU_APP_NAME web
- name: Purge Fastly cache
uses: jcoene/fastly-purge-action@master
with:
api_key: "${{ secrets.FASTLY_API_KEY_PROD_NEXTJS }}"
service_id: "${{ secrets.FASTLY_SERVICE_ID_PROD_NEXTJS }}"
# runs ONLY on a failure of the CI workflow
on-failure:
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'failure'
steps:
- run: echo 'The triggering workflow failed'