1+ ---
12name : Docker build images
23
3- on :
4+ on : # yamllint disable-line rule:truthy
45 push :
5- branches : [ "main" ]
6+ branches : ["main"]
67 pull_request :
7- branches : [ "main" ]
8+ branches : ["main"]
89
910env :
1011 AWS_REGION : eu-central-1
12+ AWS_ROLE : arn:aws:iam::615677714887:role/postgres-grafana-on-ecs-role
1113
1214permissions :
1315 id-token : write
@@ -18,28 +20,30 @@ jobs:
1820 runs-on : ubuntu-latest
1921 strategy :
2022 matrix :
21- image : [ 'grafana', 'postgres' ]
23+ image : ['grafana', 'postgres']
2224 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@v3
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/${{ matrix.image }}
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
25+ - uses : actions/checkout@v4
26+
27+ - name : Set AWS credentials
28+ uses : aws-actions/configure-aws-credentials@v4
29+ with :
30+ role-to-assume : ${{ env.AWS_ROLE }}
31+ aws-region : ${{ env.AWS_REGION }}
32+
33+ - name : Set up Docker Buildx
34+ uses : docker/setup-buildx-action@v3
35+
36+ - name : Login to Amazon ECR
37+ id : login-ecr
38+ uses : aws-actions/amazon-ecr-login@v2
39+
40+ - name : Build, tag, and push docker image to Amazon ECR
41+ uses : docker/build-push-action@v5
42+ with :
43+ context : ./src/${{ matrix.image }}
44+ push : ${{ github.event_name == 'push' &&
45+ github.ref == 'refs/heads/main' }}
46+ tags : " 615677714887.dkr.ecr.eu-central-1.amazonaws.com/\
47+ postgres-grafana-on-ecs-${{ matrix.image }}-repo"
48+ cache-from : type=gha
49+ cache-to : type=gha,mode=max
0 commit comments