Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teste local #180

Closed
wants to merge 13 commits into from
48 changes: 48 additions & 0 deletions .github/workflows/docker-image-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Push Docker Image to AWS ECR

on:
pull_request:
branches: [ main, hmg ]
types: closed

jobs:
deploy:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
strategy:
matrix:
environment:
- { name: "homologation", branch: "hmg", repository: "vagas-hmg" }
- { name: "production", branch: "main", repository: "vagas" }

name: Deploy to ${{ matrix.environment.name }}
steps:
- name: Check branch match
id: branch_check
run: |
if [[ "${{ github.base_ref }}" != "${{ matrix.environment.branch }}" ]]; then
exit 1
fi

- name: Checkout
uses: actions/checkout@v2

- 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: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, Tag, and Push the Image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ matrix.environment.repository }}
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
Loading