-
Notifications
You must be signed in to change notification settings - Fork 5
116 lines (94 loc) · 3.55 KB
/
local-illinois.yml
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Local Illinois ECR
on:
workflow_dispatch:
env:
SITE_ENV: "local"
LOCAL_ID: "illinois"
ECR_REPOSITORY: "dpla-local-illinois"
GA_TRACKING_ID: "UA-142501884-1"
WORDPRESS_URL: "https://dpla.wpengine.com"
USER_BASE_URL: "https://idhh.dp.la"
PRO_BASE_URL: "https://pro.dp.la"
PSS_BASE_URL: "https://dp.la/pssapi"
jobs:
ecr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Read .nvmrc
run: echo "{NODE_VERSION}={cat .nvmrc}" >> $GITHUB_OUTPUT
id: nvm
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: arm64,arm
- name: Use Node.js ${{ steps.nvm.outputs.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
- name: Install Yarn
run: npm install -g yarn
- name: Set AWS credentials
if: ${{ !env.ACT }}
uses: aws-actions/configure-aws-credentials@v2
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
if: ${{ !env.ACT }}
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Delete Exhibitions from app
run: |
rm -rf pages/exhibitions
shell: bash
# Building the frontend app
- name: Create and populate constants/env.js
run: |
touch constants/env.js
echo "export const SITE_ENV = \"$SITE_ENV\";" >> constants/env.js
echo "export const USER_BASE_URL = \"$USER_BASE_URL\";" >> constants/env.js
echo "export const WORDPRESS_URL = \"$WORDPRESS_URL\";" >> constants/env.js
echo "export const PRO_BASE_URL = \"$PRO_BASE_URL\";" >> constants/env.js
echo "export const PSS_BASE_URL = \"$PSS_BASE_URL\";" >> constants/env.js
echo "export const LOCAL_ID = \"$LOCAL_ID\";" >> constants/env.js
echo "export const gaTrackingId = \"$GA_TRACKING_ID\";" >> constants/env.js
shell: bash
- name: Add path
run: |
echo "HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin" >> $GITHUB_PATH
shell: bash
- name: Build the app with Yarn
run: |
yarn clean
yarn build
shell: bash
# Get branch names for ECR tagging
- name: Get branch name (merge)
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: Get branch name (pull request)
if: github.event_name == 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
# Push to ECR
- name: Build, tag, and push image to Amazon ECR
if: ${{ !env.ACT }}
id: build-image
env:
IMAGE_TAG: ${{ github.sha }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker buildx build \
-t $ECR_REGISTRY/$ECR_REPOSITORY:latest \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$BRANCH_NAME \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
--platform linux/amd64,linux/arm64 . \
--push