Create aws.yml

This commit is contained in:
darefjev44 2024-04-20 14:10:47 +01:00 committed by GitHub
parent e8e6366bde
commit d0efa2ffa3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

33
.github/workflows/aws.yml vendored Normal file
View file

@ -0,0 +1,33 @@
name: Push to AWS ECR
on:
workflow_run:
workflows: ['Docker Image CI']
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION}}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Pull image from GHCR
run: docker pull ghcr.io/${{ github.repository }}/spring-petclinic:latest
- name: Tag the image for ECR
run: docker tag ghcr.io/${{ github.repository }}/spring-petclinic:latest ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/spring-petclinic:latest
- name: Push image to Amazon ECR
run: docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/spring-petclinic:latest