Release 0.18.9 to production #42
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 merge to production, | |
# build a container and deploy to ECR | |
name: Publish Production | |
on: | |
pull_request: | |
branches: [production] | |
types: [closed] | |
jobs: | |
tag_release: | |
name: Tag and Release | |
# only run if PR is merged (not just closed) | |
if: github.event.pull_request.merged | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# the tag will match the package.json version (eg. v1.0.0) | |
- name: Tag | |
id: autotagger | |
uses: butlerlogic/[email protected] | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
with: | |
strategy: package | |
tag_prefix: v | |
# use the body of the PR commit as the tag message | |
tag_message: ${{ github.event.pull_request.body }} | |
- name: Release | |
id: create_release | |
if: steps.autotagger.outputs.tagname != '' | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.autotagger.outputs.tagname }} | |
name: ${{ steps.autotagger.outputs.tagname }} | |
# use the body of the PR commit as the release body | |
body: ${{ github.event.pull_request.body }} | |
draft: false | |
prerelease: false | |
publish_qa: | |
name: Publish image to ECR | |
if: github.event.pull_request.merged | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: npm | |
- name: Configure AWS credentials from Test account | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
APP_ENV: production | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: sfr-front-end | |
IMAGE_TAG: ${{ github.sha }} | |
AIRTABLE_KEY: ${{ secrets.AIRTABLE_API_KEY }} | |
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} | |
run: | | |
docker build --build-arg airtable_api_key=$AIRTABLE_KEY -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ | |
--build-arg APP_ENV=$APP_ENV \ | |
--build-arg NEW_RELIC_APP_NAME="Digital Research Books (PROD)" \ | |
--build-arg NEW_RELIC_LICENSE_KEY=$NEW_RELIC_LICENSE_KEY \ | |
--build-arg NEXT_PUBLIC_ADOBE_ANALYTICS="https://assets.adobedtm.com/1a9376472d37/8519dfce636d/launch-672b7e7f98ee.min.js" . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:production-latest | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:production-latest | |
- name: Force ECS Update | |
run: | | |
aws ecs update-service --cluster sfr-front-end-production --service sfr-front-end-production --force-new-deployment |