-
Notifications
You must be signed in to change notification settings - Fork 1
45 lines (41 loc) · 1.29 KB
/
prod.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
name: Build & push container image
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
submodules: true
- name: Get AWS ops credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_IAM_ROLE_ARN_PROD }}
role-session-name: github-action-tx-latency-measurement
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
id: login-ecr
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY_PROD }}
run: |
git_hash=$(git rev-parse --short "$GITHUB_SHA")
for dir in */; do
dir=${dir%/}
if [ -f "$dir/Dockerfile" ]; then
cd $dir
echo "Building image in $dir"
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$dir-$git_hash .
cd -
fi
done
docker push $ECR_REGISTRY/$ECR_REPOSITORY --all-tags