-
Notifications
You must be signed in to change notification settings - Fork 24
55 lines (47 loc) · 1.64 KB
/
build-ampd-main.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
name: ampd (push to main) - Build and push image to ECR
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-push-latest-docker-image:
runs-on: ubuntu-22.04
permissions:
id-token: write
contents: read
env:
REPOSITORY: axelar-amplifier
IMAGE_TAG: ${{ github.sha }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: fetch tags
run: |
git fetch --unshallow
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: us-east-2
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ghwf-${{ github.event.repository.name }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: check if an image already build on same commit hash
id: image-tag-check
run: |
image_tag_exists=$(aws ecr batch-get-image --repository-name ${REPOSITORY} --image-ids "imageTag=${IMAGE_TAG}" | jq '.images | length')
echo "image_tag_exists=${image_tag_exists}" >> $GITHUB_OUTPUT
- uses: docker/setup-buildx-action@v3
if: steps.image-tag-check.outputs.image_tag_exists == 0
- uses: docker/build-push-action@v5
if: steps.image-tag-check.outputs.image_tag_exists == 0
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
with:
context: .
push: true
tags: ${{env.REGISTRY}}/${{env.REPOSITORY}}:${{env.IMAGE_TAG}}
file: ampd/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max