From 21f461969e0258d4c1d11ac328ccefa39910a7ad Mon Sep 17 00:00:00 2001 From: pvdevs Date: Mon, 28 Oct 2024 21:24:55 -0300 Subject: [PATCH 1/8] WIP --- .github/workflows/docker-image-pr.yml | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/docker-image-pr.yml diff --git a/.github/workflows/docker-image-pr.yml b/.github/workflows/docker-image-pr.yml new file mode 100644 index 0000000..f837fc6 --- /dev/null +++ b/.github/workflows/docker-image-pr.yml @@ -0,0 +1,42 @@ +--- +name: Build and Push Docker Image to AWS ECR +on: + pull_request: + branches: [ main ] + types: closed + +jobs: + build-and-push: + if: github.event.pull_request.merged == true + name: Build and Push to ECR + runs-on: ubuntu-latest + + steps: + - 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: Automatic Tagging of Releases + id: increment-git-tag + run: | + bash ./build/git_update.sh -v major + + - name: Build, Tag, and Push the Image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: testing + IMAGE_TAG: latest + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ No newline at end of file From d4e7215e1996161edc44cbaca8b1f78a539551a3 Mon Sep 17 00:00:00 2001 From: pvdevs Date: Mon, 28 Oct 2024 21:27:22 -0300 Subject: [PATCH 2/8] empty commit From be6b7067b0d006aa3ecba450b503cbb45cb7a580 Mon Sep 17 00:00:00 2001 From: pvdevs Date: Mon, 28 Oct 2024 21:35:46 -0300 Subject: [PATCH 3/8] empty commit From 6e4632e645260223ba39ebe06873f9fc5598f170 Mon Sep 17 00:00:00 2001 From: pvdevs Date: Mon, 28 Oct 2024 21:40:07 -0300 Subject: [PATCH 4/8] WIP --- .github/workflows/docker-image-pr.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/docker-image-pr.yml b/.github/workflows/docker-image-pr.yml index f837fc6..f01a91d 100644 --- a/.github/workflows/docker-image-pr.yml +++ b/.github/workflows/docker-image-pr.yml @@ -26,11 +26,6 @@ jobs: id: login-ecr uses: aws-actions/amazon-ecr-login@v1 - - name: Automatic Tagging of Releases - id: increment-git-tag - run: | - bash ./build/git_update.sh -v major - - name: Build, Tag, and Push the Image to Amazon ECR id: build-image env: From b3d1481943914cc4e6924b5c198196c9a8ae8f6b Mon Sep 17 00:00:00 2001 From: pvdevs Date: Mon, 28 Oct 2024 21:42:41 -0300 Subject: [PATCH 5/8] empty commit From 3ceed671f04d5cf30f6f6d2d961688e43e54fcc2 Mon Sep 17 00:00:00 2001 From: pvdevs Date: Tue, 29 Oct 2024 09:12:11 -0300 Subject: [PATCH 6/8] WIP --- .github/workflows/docker-image-pr.yml | 39 +++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-image-pr.yml b/.github/workflows/docker-image-pr.yml index f01a91d..1869d04 100644 --- a/.github/workflows/docker-image-pr.yml +++ b/.github/workflows/docker-image-pr.yml @@ -1,4 +1,3 @@ ---- name: Build and Push Docker Image to AWS ECR on: pull_request: @@ -6,10 +5,10 @@ on: types: closed jobs: - build-and-push: - if: github.event.pull_request.merged == true - name: Build and Push to ECR + deploy_hmg: + if: github.event.pull_request.merged == true && github.head_ref == 'hmg' runs-on: ubuntu-latest + name: Deploy to Homologation steps: - name: Checkout @@ -30,7 +29,37 @@ jobs: id: build-image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: testing + ECR_REPOSITORY: vagas-hmg + IMAGE_TAG: latest + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + + deploy_producao: + if: github.event.pull_request.merged == true && github.head_ref == 'main' + runs-on: ubuntu-latest + name: Deploy to Production + + steps: + - 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 + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: vagas IMAGE_TAG: latest run: | docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . From a64a2faf4b9873ceb166b864b0da6d423a1b373d Mon Sep 17 00:00:00 2001 From: pvdevs Date: Tue, 29 Oct 2024 10:26:20 -0300 Subject: [PATCH 7/8] WIP --- .github/workflows/docker-image-pr.yml | 96 +++++++++++---------------- 1 file changed, 39 insertions(+), 57 deletions(-) diff --git a/.github/workflows/docker-image-pr.yml b/.github/workflows/docker-image-pr.yml index 1869d04..80d129f 100644 --- a/.github/workflows/docker-image-pr.yml +++ b/.github/workflows/docker-image-pr.yml @@ -1,66 +1,48 @@ name: Build and Push Docker Image to AWS ECR + on: pull_request: - branches: [ main ] + branches: [ main, hmg ] types: closed jobs: - deploy_hmg: - if: github.event.pull_request.merged == true && github.head_ref == 'hmg' + deploy: + if: github.event.pull_request.merged == true runs-on: ubuntu-latest - name: Deploy to Homologation + strategy: + matrix: + environment: + - { name: "homologation", branch: "hmg", repository: "vagas-hmg" } + - { name: "production", branch: "main", repository: "vagas" } + name: Deploy to ${{ matrix.environment.name }} steps: - - 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 - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: vagas-hmg - IMAGE_TAG: latest - run: | - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - - deploy_producao: - if: github.event.pull_request.merged == true && github.head_ref == 'main' - runs-on: ubuntu-latest - name: Deploy to Production - - steps: - - 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 - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: vagas - IMAGE_TAG: latest - run: | - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ No newline at end of file + - 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 \ No newline at end of file From 14a91a2ca98f2205339481502d4e9156a4481b70 Mon Sep 17 00:00:00 2001 From: pvdevs Date: Tue, 29 Oct 2024 10:27:09 -0300 Subject: [PATCH 8/8] empty commit