Skip to content

Commit 410ec1a

Browse files
committed
Added GitHub action for docker image building
As per subject, builds a docker image on every git commit and pushes the image to AWS ECR
1 parent dc288cb commit 410ec1a

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

.github/workflows/build_image.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build and upload docker images
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
permissions:
9+
id-token: write # for JWT request
10+
contents: read # for actions/checkout
11+
12+
jobs:
13+
docker-image-build:
14+
name: docker-image-build
15+
runs-on: ubuntu-latest
16+
environment: preprod
17+
steps:
18+
- name: Checkout repo
19+
uses: actions/checkout@v4.1.7
20+
- name: Configure AWS Credentials
21+
uses: aws-actions/configure-aws-credentials@v4.0.2
22+
with:
23+
role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME }}
24+
aws-region: eu-west-2
25+
role-session-name: github-aws-access
26+
- name: Login to Amazon ECR
27+
id: login-ecr
28+
uses: aws-actions/amazon-ecr-login@v2.0.1
29+
- name: Build fb-user-datastore, tag, and push docker image to Amazon ECR
30+
env:
31+
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
32+
REPOSITORY: "fb-user-datastore"
33+
IMAGE_TAG: ${{ github.sha }}
34+
run: |
35+
docker build -t ${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} .
36+
docker tag ${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
37+
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}

0 commit comments

Comments
 (0)