|
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 |
2 | 48 |
|
3 | 49 | # on:
|
4 | 50 | # push:
|
5 | 51 | # branches:
|
6 | 52 | # - main
|
7 | 53 |
|
8 | 54 | # env:
|
9 |
| -# AWS_REGION: "eu-central-1" # set this to your preferred AWS region, e.g. us-west-1 |
| 55 | +# AWS_REGION: "us-east-1" # Your preferred AWS region |
10 | 56 |
|
11 | 57 | # jobs:
|
12 | 58 | # deploy:
|
|
28 | 74 | # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
29 | 75 | # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
30 | 76 | # 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 |
36 | 82 |
|
37 | 83 | # # Build and tag the Docker image
|
38 | 84 | # - name: Build and Tag Docker Image
|
39 | 85 | # run: |
|
40 | 86 | # 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 |
42 | 88 |
|
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 |
45 | 91 | # run: |
|
46 |
| -# docker push ${{ steps.login-ecr.outputs.registry }}/kotlin-spring-postgres-demo-app:latest |
47 |
| -name: Deploy to Public AWS ECR |
| 92 | +# docker push public.ecr.aws/b1y7k5v4/kotlin-spring-postgres-demo-app:latest |
| 93 | +name: Deploy to GitHub Container Registry |
48 | 94 |
|
49 | 95 | on:
|
50 | 96 | push:
|
51 | 97 | branches:
|
52 | 98 | - main
|
53 | 99 |
|
54 |
| -env: |
55 |
| - AWS_REGION: "us-east-1" # Your preferred AWS region |
56 |
| - |
57 | 100 | jobs:
|
58 | 101 | deploy:
|
59 | 102 | runs-on: ubuntu-latest
|
60 | 103 |
|
61 | 104 | permissions:
|
62 | 105 | contents: read
|
63 |
| - id-token: write |
| 106 | + packages: write # Required to push to GitHub Container Registry |
64 | 107 |
|
65 | 108 | steps:
|
66 | 109 | # Checkout the code
|
67 | 110 | - name: Checkout Code
|
68 | 111 | uses: actions/checkout@v3
|
69 | 112 |
|
70 |
| - # Set up AWS credentials |
71 |
| - - name: Configure AWS credentials |
72 |
| - uses: aws-actions/configure-aws-credentials@v4 |
73 |
| - with: |
74 |
| - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
75 |
| - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
76 |
| - aws-region: ${{ env.AWS_REGION }} |
77 |
| - |
78 |
| - # Authenticate to Amazon Public ECR |
79 |
| - - name: Login to Public ECR |
| 113 | + # Authenticate to GitHub Container Registry |
| 114 | + - name: Log in to GitHub Container Registry |
80 | 115 | run: |
|
81 |
| - aws ecr-public get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin public.ecr.aws |
| 116 | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin |
82 | 117 |
|
83 | 118 | # Build and tag the Docker image
|
84 | 119 | - name: Build and Tag Docker Image
|
85 | 120 | run: |
|
86 | 121 | docker build -t kotlin-spring-postgres-demo-app .
|
87 |
| - docker tag kotlin-spring-postgres-demo-app:latest public.ecr.aws/b1y7k5v4/kotlin-spring-postgres-demo-app:latest |
| 122 | + docker tag kotlin-spring-postgres-demo-app:latest ghcr.io/${{ github.repository_owner }}/kotlin-spring-postgres-demo-app:latest |
88 | 123 |
|
89 |
| - # Push the Docker image to Amazon Public ECR |
90 |
| - - name: Push Docker Image to Public ECR |
| 124 | + # Push the Docker image to GHCR |
| 125 | + - name: Push Docker Image to GitHub Container Registry |
91 | 126 | run: |
|
92 |
| - docker push public.ecr.aws/b1y7k5v4/kotlin-spring-postgres-demo-app:latest |
| 127 | + docker push ghcr.io/${{ github.repository_owner }}/kotlin-spring-postgres-demo-app:latest |
0 commit comments