Skip to content

Commit 8d89aad

Browse files
committed
Add build-and-push workflow
1 parent 068dd01 commit 8d89aad

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

.github/workflows/build-and-push.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build and Push image
2+
on:
3+
workflow_call:
4+
inputs:
5+
ECR_REGION:
6+
required: true
7+
type: string
8+
ECR_REPOSITORY:
9+
required: true
10+
type: string
11+
secrets:
12+
ECR_ROLE_TO_ASSUME:
13+
required: true
14+
15+
16+
jobs:
17+
ecr:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
id-token: write # This is required for requesting the JWT
21+
contents: read # This is required for actions/checkout
22+
steps:
23+
# Checkout GitHub repository
24+
- uses: actions/checkout@v3
25+
26+
# Assume role in Cloud Platform
27+
- uses: aws-actions/configure-aws-credentials@v2
28+
with:
29+
role-to-assume: ${{ secrets.ECR_ROLE_TO_ASSUME }}
30+
aws-region: ${{ inputs.ECR_REGION }}
31+
32+
# Login to container repository
33+
- uses: aws-actions/amazon-ecr-login@v1
34+
id: login-ecr
35+
36+
# Build and push a Docker image to the container repository
37+
- run: |
38+
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
39+
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
40+
env:
41+
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
42+
REPOSITORY: ${{ inputs.ECR_REPOSITORY }}
43+
IMAGE_TAG: ${{ github.sha }}

.github/workflows/workflow.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
on: push
2+
jobs:
3+
build-and-push:
4+
uses: ./.github/workflows/build-and-push.yml
5+
with:
6+
ECR_REGION: ${{vars.ECR_REGION}}
7+
ECR_REPOSITORY: ${{vars.ECR_REPOSITORY}}
8+
secrets:
9+
ECR_ROLE_TO_ASSUME: ${{ secrets.ECR_ROLE_TO_ASSUME }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ env/
88
*.code-workspace
99
*.sha256
1010
terraform.tfstate
11+
.idea

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM python:3.12-slim

0 commit comments

Comments
 (0)