-
Notifications
You must be signed in to change notification settings - Fork 10
81 lines (73 loc) · 2.79 KB
/
docker_build.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
name: Build and Push Images
on:
pull_request:
types: [opened, synchronize]
release:
types: [created]
push:
branches:
- main
permissions:
id-token: write
contents: read
jobs:
build:
name: Build Launch Images
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: "yarn"
cache-dependency-path: "zt_frontend/yarn.lock"
- name: Build Frontend Files
run: |
echo "Cleaning up old builds..."
rm -rf zt_backend/dist_dev/ zt_backend/dist_app/
echo "Building Frontend..."
(cd zt_frontend && yarn install && yarn build && cp -r dist/ ../zt_backend/dist_dev/)
(cd zt_frontend && yarn buildapp && cp -r dist/ ../zt_backend/dist_app/)
(cd copilot && yarn install)
shell: bash
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ARN }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ secrets.AWS_REGION }}
- name: "Build and push image via Kaniko"
if: github.ref_type == 'tag'
run: |
docker run \
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
-e AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} \
-v ${{ github.workspace }}:/workspace \
gcr.io/kaniko-project/executor:latest \
--dockerfile Dockerfile \
--reproducible --cleanup --cache=true \
--cache-repo ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}-cache \
--destination=${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:zero-true-${GITHUB_REF_NAME}-python${{ matrix.python-version }} \
--context dir:///workspace/ \
--build-arg PYTHON_VERSION=${{ matrix.python-version }}
- name: "Build and push image via Kaniko"
if: github.ref == 'refs/heads/main'
run: |
docker run \
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
-e AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} \
-v ${{ github.workspace }}:/workspace \
gcr.io/kaniko-project/executor:latest \
--dockerfile Dockerfile \
--reproducible --cleanup --cache=true \
--cache-repo ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}-cache \
--destination=${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:zero-true-v${{ github.sha }}-python${{ matrix.python-version }} \
--context dir:///workspace/ \
--build-arg PYTHON_VERSION=${{ matrix.python-version }}