-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (83 loc) · 2.93 KB
/
build-push.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
89
90
91
92
name: "Build & Push"
on:
push:
branches:
- "main"
tags:
- "*"
paths:
- "packages/**"
- "!packages/*/scripts/**"
- ".github/workflows/build-push.yaml"
jobs:
find_dockerfiles:
name: Find Dockerfiles
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.set_packages_output.outputs.packages }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Find packages
id: set_packages_output
run: |
PACKAGES=$(find packages -type f -path "*/Dockerfile" | awk -F'/' '{print $2}' | jq -R -s -c 'split("\n")[:-1]')
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
build_push_image:
name: ${{ matrix.package }}
needs: [find_dockerfiles]
runs-on: ubuntu-latest
environment: dev
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.find_dockerfiles.outputs.packages) }}
env:
DOCKER_BUILD_SUMMARY: "false"
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.IAM_ROLE_ARN }}
role-session-name: be-monorepo-build-push-${{ github.run_number }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2
- name: (latest) Docker metadata
id: meta_latest
if: ${{ github.ref_type == 'branch' }}
uses: docker/metadata-action@60a0d343a0d8a18aedee9d34e62251f752153bdb
with:
images: ${{ steps.login-ecr.outputs.registry }}/interop-be-${{ matrix.package }}
flavor: |
latest=false
prefix=
suffix=
tags: |
type=raw,value=2.x-latest
- name: (tag) Docker metadata
id: meta_tag
if: ${{ github.ref_type == 'tag' }}
uses: docker/metadata-action@60a0d343a0d8a18aedee9d34e62251f752153bdb
with:
images: ${{ steps.login-ecr.outputs.registry }}/interop-be-${{ matrix.package }}
flavor: |
latest=false
prefix=
suffix=
tags: |
type=ref,event=tag
- name: Build and push Docker image
id: build_push
uses: docker/build-push-action@a8d35412fb758de9162fd63e3fa3f0942bdedb4d
with:
context: .
file: packages/${{ matrix.package }}/Dockerfile
push: true
tags: ${{ github.ref_type == 'branch' && steps.meta_latest.outputs.tags || steps.meta_tag.outputs.tags }}
labels: ${{ github.ref_type == 'branch' && steps.meta_latest.outputs.labels || steps.meta_tag.outputs.labels }}