From 5c5e940cf742a946d824a284f539962c1b02832c Mon Sep 17 00:00:00 2001
From: "rodrigo.zamboni"
Date: Tue, 26 Apr 2022 10:40:11 -0300
Subject: [PATCH 1/3] FIX: CI
---
.github/workflows/deploy.yml | 51 ++++++++++++++++++------------------
1 file changed, 25 insertions(+), 26 deletions(-)
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 58842b3..a39c82d 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -23,19 +23,15 @@ jobs:
fi
id: extract_environment
- deploy:
- needs: extract_environment
- runs-on:
- [self-hosted, '${{ needs.extract_environment.outputs.environment }}']
+ semantic_release:
+ runs-on: ubuntu-latest
+ outputs:
+ new_release_published: ${{ steps.semantic.outputs.new_release_published }}
+ new_release_version: ${{ steps.semantic.outputs.new_release_version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- # Because Semantic Realese deleted the .npmrc file, it was necessary to insert two steps to backup the file.
- - name: BKP .npmrc Step 1
- run: |
- cp .npmrc .npmrcbkp
-
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
@@ -60,40 +56,43 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- # Because Semantic Realese deleted the .npmrc file, it was necessary to insert two steps to backup the file.
- - name: BKP .npmrc Step 2
- run: |
- cp .npmrcbkp .npmrc
+ deploy:
+ needs: [extract_environment, semantic_release]
+ runs-on: [self-hosted, "${{ needs.extract_environment.outputs.environment }}"]
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
- name: Update Pip
- if: steps.semantic.outputs.new_release_published == 'true'
+ if: needs.semantic_release.outputs.new_release_published == 'true'
run: |
python3 -m pip install --upgrade pip
- name: Install Docker Compose
- if: steps.semantic.outputs.new_release_published == 'true'
+ if: needs.semantic_release.outputs.new_release_published == 'true'
run: |
python3 -m pip install docker-compose --upgrade
- name: Install AWS CLI
- if: steps.semantic.outputs.new_release_published == 'true'
+ if: needs.semantic_release.outputs.new_release_published == 'true'
run: |
python3 -m pip install awscli --upgrade
- name: Install AWS Elastic Beanstalk CLI
- if: steps.semantic.outputs.new_release_published == 'true'
+ if: needs.semantic_release.outputs.new_release_published == 'true'
run: |
python3 -m pip install awsebcli --upgrade
- name: Configure AWS Region
- if: steps.semantic.outputs.new_release_published == 'true'
+ if: needs.semantic_release.outputs.new_release_published == 'true'
uses: aws-actions/configure-aws-credentials@v1
id: aws
with:
aws-region: us-east-1
- name: Extract Environment
- if: steps.semantic.outputs.new_release_published == 'true'
+ if: needs.semantic_release.outputs.new_release_published == 'true'
shell: bash
run: |
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
@@ -106,15 +105,15 @@ jobs:
id: extract_environment
- name: Login to AWS ECR
- if: steps.semantic.outputs.new_release_published == 'true'
+ if: needs.semantic_release.outputs.new_release_published == 'true'
id: login_ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, Tag, and Push Image to AWS ECR
- if: steps.semantic.outputs.new_release_published == 'true'
+ if: needs.semantic_release.outputs.new_release_published == 'true'
env:
ENV: ${{ steps.extract_environment.outputs.result }}
- IMAGE_TAG: ${{ steps.semantic.outputs.new_release_version }}
+ IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
@@ -122,25 +121,25 @@ jobs:
docker-compose -f build.docker-compose.yml push
- name: Create ZIP file to Deploy AWS Beanstalk
- if: steps.semantic.outputs.new_release_published == 'true'
+ if: needs.semantic_release.outputs.new_release_published == 'true'
env:
ENV: ${{ steps.extract_environment.outputs.result }}
- IMAGE_TAG: ${{ steps.semantic.outputs.new_release_version }}
+ IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
run: |
sed -i -e "s/\${ENV}/$ENV/g" docker-compose.yml
sed -i -e "s/\${IMAGE_TAG}/$IMAGE_TAG/g" docker-compose.yml
sed -i -e "s/\${ACCOUNT_ID}/$ACCOUNT_ID/g" docker-compose.yml
- zip deploy.zip docker-compose.yml -r .ebextensions
- name: Deploy AWS Beanstalk
- if: steps.semantic.outputs.new_release_published == 'true'
+ if: needs.semantic_release.outputs.new_release_published == 'true'
env:
ENV: ${{ steps.extract_environment.outputs.result }}
AWS_REGION: us-east-1
APP_NAME: maestro
run: |
eb use $APP_NAME-$ENV
+ echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml
eb deploy
- name: Remove Docker's Trash
From d4e11b19356ce90f8b5ecf0ad3df485929efabd6 Mon Sep 17 00:00:00 2001
From: "rodrigo.zamboni"
Date: Tue, 26 Apr 2022 10:48:57 -0300
Subject: [PATCH 2/3] FIX: CI
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fb3778c..f55e965 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
Maestro
-
\ No newline at end of file
+
\ No newline at end of file
From 44211d5658ad9d9f49d05cc0772d9c683ff90d56 Mon Sep 17 00:00:00 2001
From: "rodrigo.zamboni"
Date: Tue, 26 Apr 2022 11:01:20 -0300
Subject: [PATCH 3/3] FIX: CI
---
.github/workflows/deploy.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index a39c82d..ab9ff04 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -130,6 +130,7 @@ jobs:
sed -i -e "s/\${ENV}/$ENV/g" docker-compose.yml
sed -i -e "s/\${IMAGE_TAG}/$IMAGE_TAG/g" docker-compose.yml
sed -i -e "s/\${ACCOUNT_ID}/$ACCOUNT_ID/g" docker-compose.yml
+ zip deploy.zip docker-compose.yml -r .ebextensions
- name: Deploy AWS Beanstalk
if: needs.semantic_release.outputs.new_release_published == 'true'