-
Notifications
You must be signed in to change notification settings - Fork 2
88 lines (80 loc) · 3.15 KB
/
build-production.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# 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