-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (42 loc) · 1.66 KB
/
ecr-push.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: Docker image build and publish
# on:
# push:
# branches:
# - dev
# jobs:
# build-push:
# name: Build and publish container
# runs-on: ubuntu-latest
# permissions:
# id-token: write
# contents: read
# outputs:
# image_tag: ${{ steps.build-publish.outputs.image_tag }}
# steps:
# - name: Checkout repo
# uses: actions/checkout@v3
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v2
# with:
# role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_NUMBER }}:role/${{ secrets.AWS_ROLE }}
# role-session-name: updateimage
# aws-region: ${{ secrets.AWS_REGION }}
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v2
# with:
# registries: ${{ secrets.AWS_ACCOUNT_NUMBER }}
# - name: Build, tag, and push API docker image to Amazon ECR
# id: build-publish
# shell: bash
# env:
# ECR_REGISTRY: "public.ecr.aws/dewberry"
# ECR_REPOSITORY: ${{ secrets.ECR_REPO_NAME }}
# IMAGE_TAG: ${{ github.sha }}
# run: |
# docker build . -t "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
# docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
# docker tag "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" "$ECR_REGISTRY/$ECR_REPOSITORY:latest"
# docker push "$ECR_REGISTRY/$ECR_REPOSITORY:latest"
# echo "IMAGE $IMAGE_TAG is pushed to $ECR_REGISTRY/$ECR_REPOSITORY"
# echo "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG overwrote $ECR_REGISTRY/$ECR_REPOSITORY:latest"