update demo project #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |