mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-22 12:49:09 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d1a54a720 | ||
|
|
8399a0e4c1 | ||
|
|
cf54cb0bc2 | ||
|
|
2344e4dba3 |
@@ -2,37 +2,50 @@ name: Deploy
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- alpha
|
|
||||||
- beta
|
|
||||||
- main
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
environment:
|
||||||
|
description: 'Deployment environment'
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- dev
|
||||||
|
- stg
|
||||||
|
- prd
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
extract_environment:
|
extract_environment:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
environment: ${{ steps.extract_environment.outputs.environment }}
|
environment: ${{ steps.extract_environment.outputs.environment }}
|
||||||
|
env:
|
||||||
|
EVENT: ${{ github.event_name }}
|
||||||
|
DEPLOY_ENV: ${{ github.event.inputs.environment }}
|
||||||
steps:
|
steps:
|
||||||
- name: Extract Environment
|
- name: Extract Environment
|
||||||
run: |
|
run: |
|
||||||
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
if [ ${EVENT} == "workflow_dispatch" ]; then
|
||||||
|
echo "##[set-output name=environment;]$(echo ${DEPLOY_ENV})"
|
||||||
|
elif [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
||||||
echo "##[set-output name=environment;]$(echo "prd")"
|
echo "##[set-output name=environment;]$(echo "prd")"
|
||||||
elif [ ${GITHUB_REF} == "refs/heads/alpha" ]; then
|
|
||||||
echo "##[set-output name=environment;]$(echo "dev")"
|
|
||||||
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then
|
|
||||||
echo "##[set-output name=environment;]$(echo "stg")"
|
|
||||||
fi
|
fi
|
||||||
id: extract_environment
|
id: extract_environment
|
||||||
|
|
||||||
semantic_release:
|
semantic_release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
|
#new_release_published: ${{ steps.semantic.outputs.last_release_version != steps.semantic.outputs.new_release_version }}
|
||||||
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
|
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
|
||||||
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
|
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
|
||||||
|
test: ${{ (steps.semantic.outputs.new_release_published == 'true' && steps.semantic.outputs.new_release_version) || (github.event_name == 'workflow_dispatch' && '0.0.0') }}
|
||||||
|
testt: ${{ (needs.semantic_release.outputs.new_release_published == 'true' && needs.semantic_release.outputs.new_release_version) || '1.0.0' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Semantic Release
|
- if: github.event_name != 'workflow_dispatch'
|
||||||
|
name: Semantic Release
|
||||||
uses: cycjimmy/semantic-release-action@v2
|
uses: cycjimmy/semantic-release-action@v2
|
||||||
id: semantic
|
id: semantic
|
||||||
with:
|
with:
|
||||||
@@ -41,77 +54,58 @@ jobs:
|
|||||||
conventional-changelog-eslint
|
conventional-changelog-eslint
|
||||||
branches: |
|
branches: |
|
||||||
[
|
[
|
||||||
'main',
|
'main'
|
||||||
{
|
|
||||||
name: 'alpha',
|
|
||||||
prerelease: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'beta',
|
|
||||||
prerelease: true
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
|
if: ${{ (github.event_name != 'workflow_dispatch' && needs.semantic_release.outputs.new_release_published == 'true') || 'true' }}
|
||||||
needs: [extract_environment, semantic_release]
|
needs: [extract_environment, semantic_release]
|
||||||
runs-on: [self-hosted, "${{ needs.extract_environment.outputs.environment }}"]
|
runs-on:
|
||||||
|
[self-hosted, '${{ needs.extract_environment.outputs.environment }}']
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: print
|
||||||
|
env:
|
||||||
|
EVENT: ${{ github.event_name }}
|
||||||
|
IMAGE_TAG: ${{ needs.semantic_release.outputs.test }}
|
||||||
|
IMAGE_TAGG: ${{ needs.semantic_release.outputs.testT }}
|
||||||
|
run: echo ${IMAGE_TAG} ${IMAGE_TAGG} ${EVENT}
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Update Pip
|
- name: Update Pip
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
|
|
||||||
- name: Install Docker Compose
|
- name: Install Docker Compose
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install docker-compose --upgrade
|
python3 -m pip install docker-compose --upgrade
|
||||||
|
|
||||||
- name: Install AWS CLI
|
- name: Install AWS CLI
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install awscli --upgrade
|
python3 -m pip install awscli --upgrade
|
||||||
|
|
||||||
- name: Install AWS Elastic Beanstalk CLI
|
- name: Install AWS Elastic Beanstalk CLI
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install awsebcli --upgrade
|
python3 -m pip install awsebcli --upgrade
|
||||||
|
|
||||||
- name: Configure AWS Region
|
- name: Configure AWS Region
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
uses: aws-actions/configure-aws-credentials@v1
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
id: aws
|
id: aws
|
||||||
with:
|
with:
|
||||||
aws-region: us-east-1
|
aws-region: us-east-1
|
||||||
|
|
||||||
- name: Extract Environment
|
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
if [ ${GITHUB_REF} == "refs/heads/main" ]; then
|
|
||||||
echo "##[set-output name=result;]$(echo "prd")"
|
|
||||||
elif [ ${GITHUB_REF} == "refs/heads/alpha" ]; then
|
|
||||||
echo "##[set-output name=result;]$(echo "dev")"
|
|
||||||
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then
|
|
||||||
echo "##[set-output name=result;]$(echo "stg")"
|
|
||||||
fi
|
|
||||||
id: extract_environment
|
|
||||||
|
|
||||||
- name: Login to AWS ECR
|
- name: Login to AWS ECR
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
id: login_ecr
|
id: login_ecr
|
||||||
uses: aws-actions/amazon-ecr-login@v1
|
uses: aws-actions/amazon-ecr-login@v1
|
||||||
|
|
||||||
- name: Build, Tag, and Push Image to AWS ECR
|
- name: Build, Tag, and Push Image to AWS ECR
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
env:
|
env:
|
||||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||||
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
||||||
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
@@ -120,9 +114,8 @@ jobs:
|
|||||||
docker-compose -f build.docker-compose.yml push
|
docker-compose -f build.docker-compose.yml push
|
||||||
|
|
||||||
- name: Create ZIP file to Deploy AWS Beanstalk
|
- name: Create ZIP file to Deploy AWS Beanstalk
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
env:
|
env:
|
||||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||||
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
|
||||||
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
|
||||||
run: |
|
run: |
|
||||||
@@ -132,11 +125,10 @@ jobs:
|
|||||||
zip deploy.zip docker-compose.yml -r .ebextensions
|
zip deploy.zip docker-compose.yml -r .ebextensions
|
||||||
|
|
||||||
- name: Deploy AWS Beanstalk
|
- name: Deploy AWS Beanstalk
|
||||||
if: needs.semantic_release.outputs.new_release_published == 'true'
|
|
||||||
env:
|
env:
|
||||||
ENV: ${{ steps.extract_environment.outputs.result }}
|
ENV: ${{ needs.extract_environment.outputs.environment }}
|
||||||
AWS_REGION: us-east-1
|
AWS_REGION: us-east-1
|
||||||
APP_NAME: maestro
|
APP_NAME: ${{ github.event.repository.name }}
|
||||||
run: |
|
run: |
|
||||||
eb use $APP_NAME-$ENV
|
eb use $APP_NAME-$ENV
|
||||||
echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml
|
echo -e "deploy:\n artifact: deploy.zip" >> .elasticbeanstalk/config.yml
|
||||||
Reference in New Issue
Block a user