Skip to content

Commit a47e0e7

Browse files
committed
push demo image to public repo in ecr
1 parent d9a8b4e commit a47e0e7

File tree

1 file changed

+57
-11
lines changed

1 file changed

+57
-11
lines changed

.github/workflows/deploy-to-ecr.yaml

+57-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,58 @@
1-
name: Deploy to AWS ECR
1+
# name: Deploy to AWS ECR
2+
3+
# on:
4+
# push:
5+
# branches:
6+
# - main
7+
8+
# env:
9+
# AWS_REGION: "eu-central-1" # set this to your preferred AWS region, e.g. us-west-1
10+
11+
# jobs:
12+
# deploy:
13+
# runs-on: ubuntu-latest
14+
15+
# permissions:
16+
# contents: read
17+
# id-token: write
18+
19+
# steps:
20+
# # Checkout the code
21+
# - name: Checkout Code
22+
# uses: actions/checkout@v3
23+
24+
# # Set up AWS credentials
25+
# - name: Configure AWS credentials
26+
# uses: aws-actions/configure-aws-credentials@v4
27+
# with:
28+
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
29+
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
30+
# aws-region: ${{ env.AWS_REGION }}
31+
32+
# # Login to Amazon ECR
33+
# - name: Login to Amazon ECR
34+
# id: login-ecr
35+
# uses: aws-actions/amazon-ecr-login@v2
36+
37+
# # Build and tag the Docker image
38+
# - name: Build and Tag Docker Image
39+
# run: |
40+
# docker build -t kotlin-spring-postgres-demo-app .
41+
# docker tag kotlin-spring-postgres-demo-app:latest ${{ steps.login-ecr.outputs.registry }}/kotlin-spring-postgres-demo-app:latest
42+
43+
# # Push the Docker image to Amazon ECR
44+
# - name: Push Docker Image to Amazon ECR
45+
# run: |
46+
# docker push ${{ steps.login-ecr.outputs.registry }}/kotlin-spring-postgres-demo-app:latest
47+
name: Deploy to Public AWS ECR
248

349
on:
450
push:
551
branches:
652
- main
753

854
env:
9-
AWS_REGION: "eu-central-1" # set this to your preferred AWS region, e.g. us-west-1
55+
AWS_REGION: "eu-central-1" # Your preferred AWS region
1056

1157
jobs:
1258
deploy:
@@ -28,19 +74,19 @@ jobs:
2874
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
2975
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
3076
aws-region: ${{ env.AWS_REGION }}
31-
32-
# Login to Amazon ECR
33-
- name: Login to Amazon ECR
34-
id: login-ecr
35-
uses: aws-actions/amazon-ecr-login@v2
77+
78+
# Authenticate to Amazon Public ECR
79+
- name: Login to Public ECR
80+
run: |
81+
aws ecr-public get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin public.ecr.aws
3682
3783
# Build and tag the Docker image
3884
- name: Build and Tag Docker Image
3985
run: |
4086
docker build -t kotlin-spring-postgres-demo-app .
41-
docker tag kotlin-spring-postgres-demo-app:latest ${{ steps.login-ecr.outputs.registry }}/kotlin-spring-postgres-demo-app:latest
87+
docker tag kotlin-spring-postgres-demo-app:latest public.ecr.aws/b1y7k5v4/kotlin-spring-postgres-demo-app:latest
4288
43-
# Push the Docker image to Amazon ECR
44-
- name: Push Docker Image to Amazon ECR
89+
# Push the Docker image to Amazon Public ECR
90+
- name: Push Docker Image to Public ECR
4591
run: |
46-
docker push ${{ steps.login-ecr.outputs.registry }}/kotlin-spring-postgres-demo-app:latest
92+
docker push public.ecr.aws/b1y7k5v4/kotlin-spring-postgres-demo-app:latest

0 commit comments

Comments
 (0)