diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 58842b3..ab9ff04 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,10 +121,10 @@ 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 @@ -134,13 +133,14 @@ jobs: 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 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