Skip to content

Commit c8c5948

Browse files
committed
Add github action to build docker images
1 parent 6ef1192 commit c8c5948

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Docker build images
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
AWS_REGION: eu-central-1
11+
12+
permissions:
13+
id-token: write
14+
contents: read
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
image: [ 'grafana', 'postgres' ]
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set AWS credentials
26+
uses: aws-actions/configure-aws-credentials@v4
27+
with:
28+
role-to-assume: arn:aws:iam::615677714887:role/postgres-grafana-on-ecs-role
29+
aws-region: ${{ env.AWS_REGION }}
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v1
33+
34+
- name: Login to Amazon ECR
35+
id: login-ecr
36+
uses: aws-actions/amazon-ecr-login@v2
37+
38+
- name: Build, tag, and push docker image to Amazon ECR
39+
uses: docker/build-push-action@v5
40+
with:
41+
context: ./src/grafana
42+
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
43+
tags: 615677714887.dkr.ecr.eu-central-1.amazonaws.com/postgres-grafana-on-ecs-${{ matrix.image }}-repo
44+
cache-from: type=gha
45+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)