-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (42 loc) · 1.35 KB
/
build_and_push_to_ecr.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
name: Build and Push to ECR
on:
workflow_dispatch: # Allow manual triggering
push:
branches:
- main
concurrency:
group: build-and-push-${{ github.ref }}
cancel-in-progress: true
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
build-and-push-to-ecr:
runs-on: ubuntu-latest
steps:
- name: "Checkout source code"
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.GHA_OIDC_ROLE }}
aws-region: us-gov-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: Build Docker Image And Push to ECR
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPOSITORY }}:${{ github.sha }}
${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPOSITORY }}:latest
cache-from: type=registry,ref=${{ secrets.ECR_REPOSITORY }}
cache-to: type=inline
- name: Notify on Failure
if: failure()
run: |
echo "Build or push failed"