Skip to content

Commit 3f30d89

Browse files
committed
chore: publish docker image to ECR
1 parent 6a3b32a commit 3f30d89

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

.github/workflows/ci.yml

+19-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ on:
66
- main
77

88
permissions:
9+
# Grants the workflow permission to create OpenID Connect (OIDC) ID tokens.
910
id-token: write
11+
# Grants the workflow read-only access to the repository contents.
1012
contents: read
1113

1214
jobs:
@@ -55,6 +57,9 @@ jobs:
5557
SHA=$(echo $GITHUB_SHA | head -c7)
5658
echo "sha=$SHA" >> $GITHUB_OUTPUT
5759
60+
# ------------------------------------------------------------
61+
# Exemplo de publicação no ECR
62+
# ------------------------------------------------------------
5863
- name: Configure AWS credentials
5964
uses: aws-actions/configure-aws-credentials@v4
6065
with:
@@ -65,21 +70,28 @@ jobs:
6570
id: login-ecr
6671
uses: aws-actions/amazon-ecr-login@v2
6772

73+
- name: Build and Push Docker image
74+
env:
75+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
76+
TAG: ${{ steps.create_tag.outputs.sha }}
77+
run: |
78+
docker build -t $ECR_REGISTRY/rcmonteiro_devops_nest_ci:$TAG .
79+
docker push $ECR_REGISTRY/rcmonteiro_devops_nest_ci:$TAG
80+
81+
# ------------------------------------------------------------
6882
# Exemplo de publicação no Docker Hub
83+
# ------------------------------------------------------------
6984
# - name: Login on Container Registry
7085
# uses: docker/login-action@v3
7186
# with:
7287
# username: ${{ secrets.DOCKERHUB_USERNAME }}
7388
# password: ${{ secrets.DOCKERHUB_TOKEN }}
74-
7589
# - name: Build and Push to Docker
7690
# uses: docker/build-push-action@v5
7791
# with:
7892
# push: true
7993
# tags: rcmonteiro/devops-sample-api-ci:${{ steps.create_tag.outputs.sha }},rcmonteiro/devops-sample-api-ci:latest
80-
81-
# - name: Build docker image
82-
# run: docker build -t rcmonteiro/devops-sample-api-ci:${{ steps.create_tag.outputs.sha }} .
83-
#
84-
# - name: Push image to container registry
85-
# run: docker push rcmonteiro/devops-sample-api-ci:${{ steps.create_tag.outputs.sha }}
94+
# - name: Build docker image
95+
# run: docker build -t rcmonteiro/devops-sample-api-ci:${{ steps.create_tag.outputs.sha }} .
96+
# - name: Push image to Docker Hub
97+
# run: docker push rcmonteiro/devops-sample-api-ci:${{ steps.create_tag.outputs.sha }}

0 commit comments

Comments
 (0)