Skip to content

push to us-east-1 public repo #6

push to us-east-1 public repo

push to us-east-1 public repo #6

# name: Deploy to AWS ECR
# on:
# push:
# branches:
# - main
# env:
# AWS_REGION: "eu-central-1" # set this to your preferred AWS region, e.g. us-west-1
# jobs:
# deploy:
# runs-on: ubuntu-latest
# permissions:
# contents: read
# id-token: write
# steps:
# # Checkout the code
# - name: Checkout Code
# uses: actions/checkout@v3
# # Set up AWS credentials
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ env.AWS_REGION }}
# # Login to Amazon ECR
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v2
# # Build and tag the Docker image
# - name: Build and Tag Docker Image
# run: |
# docker build -t kotlin-spring-postgres-demo-app .
# docker tag kotlin-spring-postgres-demo-app:latest ${{ steps.login-ecr.outputs.registry }}/kotlin-spring-postgres-demo-app:latest
# # Push the Docker image to Amazon ECR
# - name: Push Docker Image to Amazon ECR
# run: |
# docker push ${{ steps.login-ecr.outputs.registry }}/kotlin-spring-postgres-demo-app:latest
name: Deploy to Public AWS ECR
on:
push:
branches:
- main
env:
AWS_REGION: "us-east-1" # Your preferred AWS region
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
# Checkout the code
- name: Checkout Code
uses: actions/checkout@v3
# Set up AWS credentials
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
# Authenticate to Amazon Public ECR
- name: Login to Public ECR
run: |
aws ecr-public get-login-password --region ${{ env.AWS_REGION }} | docker login --username AWS --password-stdin public.ecr.aws
# Build and tag the Docker image
- name: Build and Tag Docker Image
run: |
docker build -t kotlin-spring-postgres-demo-app .
docker tag kotlin-spring-postgres-demo-app:latest public.ecr.aws/b1y7k5v4/kotlin-spring-postgres-demo-app:latest
# Push the Docker image to Amazon Public ECR
- name: Push Docker Image to Public ECR
run: |
docker push public.ecr.aws/b1y7k5v4/kotlin-spring-postgres-demo-app:latest