Skip to content

Commit 2cb6fdf

Browse files
committed
add ci workflow
1 parent e14dd7b commit 2cb6fdf

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- main
12+
13+
env:
14+
ECR_REGISTRY: ${{ vars.ECR_REGISTRY }}
15+
ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }}
16+
AWS_REGION: ${{ vars.AWS_REGION }}
17+
18+
permissions:
19+
id-token: write
20+
contents: read
21+
22+
jobs:
23+
build-and-push:
24+
runs-on: [mend-self-hosted, profile=arch-small]
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Extract metadata
31+
id: meta
32+
uses: docker/metadata-action@v5
33+
with:
34+
images: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}
35+
tags: |
36+
type=ref,event=branch
37+
type=sha,prefix=sha-,format=short
38+
type=raw,value=latest,enable={{is_default_branch}}
39+
40+
- name: Build and push Docker image
41+
uses: mend/gh-actions/.github/workflows/[email protected]
42+
with:
43+
repository: ${{ env.ECR_REPOSITORY }}
44+
image-tag: ${{ steps.meta.outputs.tags }}
45+
dockerfile-path: .
46+
aws-role-to-assume: ${{ vars.AWS_IAM_ROLE_ARN }}
47+
aws-region: ${{ env.AWS_REGION }}
48+
push: ${{ github.event_name != 'pull_request' }}

0 commit comments

Comments
 (0)