feat: Alteração trigger deploy branch master para dev
This commit is contained in:
@ -5,7 +5,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
#- dev
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint_commits:
|
lint_commits:
|
||||||
@ -24,12 +23,11 @@ jobs:
|
|||||||
run: npm ci --no-audit
|
run: npm ci --no-audit
|
||||||
|
|
||||||
- name: Lint Commit Messages
|
- name: Lint Commit Messages
|
||||||
# Se qualquer mensagem não corresponder ao Conventional Commits, este step falha
|
|
||||||
run: npx commitlint --from=origin/master --to=HEAD
|
run: npx commitlint --from=origin/master --to=HEAD
|
||||||
|
|
||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
needs: lint_commits # só roda se lint_commits passar
|
needs: lint_commits
|
||||||
runs-on: [self-hosted]
|
runs-on: [self-hosted]
|
||||||
outputs:
|
outputs:
|
||||||
sha_short: ${{ steps.commit_short.outputs.sha_short }}
|
sha_short: ${{ steps.commit_short.outputs.sha_short }}
|
||||||
@ -71,7 +69,7 @@ jobs:
|
|||||||
build_and_push:
|
build_and_push:
|
||||||
name: Docker | Build and Push
|
name: Docker | Build and Push
|
||||||
needs: release
|
needs: release
|
||||||
if: ${{ needs.release.outputs.is_tagged == 'true' }} # só roda se semantic-release criou tag
|
if: ${{ needs.release.outputs.is_tagged == 'true' }}
|
||||||
runs-on: [self-hosted]
|
runs-on: [self-hosted]
|
||||||
env:
|
env:
|
||||||
DEJO_NODE_AWS_REGION: us-east-1
|
DEJO_NODE_AWS_REGION: us-east-1
|
||||||
@ -114,6 +112,8 @@ jobs:
|
|||||||
password: ${{ secrets.DEJO_NODE_AWS_SECRET_KEY }}
|
password: ${{ secrets.DEJO_NODE_AWS_SECRET_KEY }}
|
||||||
|
|
||||||
- name: Build and Push Backend
|
- name: Build and Push Backend
|
||||||
|
id: build_push
|
||||||
|
continue-on-error: true
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@ -125,11 +125,29 @@ jobs:
|
|||||||
cache-from: type=local,src=/tmp/.buildx-cache
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
|
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
|
- name: Discord | Notify Error (Build)
|
||||||
|
if: steps.build_push.outcome == 'failure' && env.DISABLE_DISCORD_NOTIFY != 'true'
|
||||||
|
run: |
|
||||||
|
curl -X POST -H "Content-Type: application/json" \
|
||||||
|
-d '{"content":":x: Falha no build/push do Docker. Veja logs."}' \
|
||||||
|
"${DISCORD_WEBHOOK}"
|
||||||
|
|
||||||
|
- name: Fail job if build_push failed
|
||||||
|
if: steps.build_push.outcome == 'failure'
|
||||||
|
run: exit 1
|
||||||
|
|
||||||
- name: Moving Cache
|
- name: Moving Cache
|
||||||
run: |
|
run: |
|
||||||
rm -rf /tmp/.buildx-cache
|
rm -rf /tmp/.buildx-cache
|
||||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Discord | Notify Success (Build)
|
||||||
|
if: steps.build_push.outcome == 'success' && env.DISABLE_DISCORD_NOTIFY != 'true'
|
||||||
|
run: |
|
||||||
|
curl -X POST -H "Content-Type: application/json" \
|
||||||
|
-d '{"content":":white_check_mark: Build e push do Docker concluídos com sucesso."}' \
|
||||||
|
"${DISCORD_WEBHOOK}"
|
||||||
|
|
||||||
kustomize_apply:
|
kustomize_apply:
|
||||||
name: Kubernetes | Kustomize Apply
|
name: Kubernetes | Kustomize Apply
|
||||||
needs: build_and_push
|
needs: build_and_push
|
||||||
@ -137,6 +155,8 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DEJO_NODE_AWS_REGION: us-east-1
|
DEJO_NODE_AWS_REGION: us-east-1
|
||||||
KUBE_NAMESPACE: dejo-node
|
KUBE_NAMESPACE: dejo-node
|
||||||
|
DISABLE_DISCORD_NOTIFY: false
|
||||||
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@ -151,11 +171,31 @@ jobs:
|
|||||||
aws-region: ${{ env.DEJO_NODE_AWS_REGION }}
|
aws-region: ${{ env.DEJO_NODE_AWS_REGION }}
|
||||||
|
|
||||||
- name: Apply Kustomize
|
- name: Apply Kustomize
|
||||||
|
id: kustomize
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.DEJO_NODE_KUBE_CONFIG_DATA_DEV }}" | base64 -d > kubeconfig
|
echo "${{ secrets.DEJO_NODE_KUBE_CONFIG_DATA_DEV }}" | base64 -d > kubeconfig
|
||||||
export KUBECONFIG=$PWD/kubeconfig
|
export KUBECONFIG=$PWD/kubeconfig
|
||||||
kubectl apply -k infrastructure/kubernetes/dev -n "${KUBE_NAMESPACE}"
|
kubectl apply -k infrastructure/kubernetes/dev -n "${KUBE_NAMESPACE}"
|
||||||
|
|
||||||
|
- name: Discord | Notify Error (Kustomize)
|
||||||
|
if: steps.kustomize.outcome == 'failure' && env.DISABLE_DISCORD_NOTIFY != 'true'
|
||||||
|
run: |
|
||||||
|
curl -X POST -H "Content-Type: application/json" \
|
||||||
|
-d '{"content":":x: Falha ao aplicar Kustomize. Veja logs."}' \
|
||||||
|
"${DISCORD_WEBHOOK}"
|
||||||
|
|
||||||
|
- name: Fail job if kustomize failed
|
||||||
|
if: steps.kustomize.outcome == 'failure'
|
||||||
|
run: exit 1
|
||||||
|
|
||||||
|
- name: Discord | Notify Success (Kustomize)
|
||||||
|
if: steps.kustomize.outcome == 'success' && env.DISABLE_DISCORD_NOTIFY != 'true'
|
||||||
|
run: |
|
||||||
|
curl -X POST -H "Content-Type: application/json" \
|
||||||
|
-d '{"content":":white_check_mark: Kustomize aplicado com sucesso."}' \
|
||||||
|
"${DISCORD_WEBHOOK}"
|
||||||
|
|
||||||
deploy_backend:
|
deploy_backend:
|
||||||
name: Kubernetes | Deploy App
|
name: Kubernetes | Deploy App
|
||||||
needs: kustomize_apply
|
needs: kustomize_apply
|
||||||
@ -165,7 +205,7 @@ jobs:
|
|||||||
AWS_ECR_REPOSITORY: dev-dejo/dejo-node
|
AWS_ECR_REPOSITORY: dev-dejo/dejo-node
|
||||||
KUBE_NAMESPACE: dejo-node
|
KUBE_NAMESPACE: dejo-node
|
||||||
KUBE_DEPLOY_NAME: api-app
|
KUBE_DEPLOY_NAME: api-app
|
||||||
DISABLE_DISCORD_NOTIFY: true
|
DISABLE_DISCORD_NOTIFY: false
|
||||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
sha_short: ${{ needs.release.outputs.sha_short }}
|
sha_short: ${{ needs.release.outputs.sha_short }}
|
||||||
steps:
|
steps:
|
||||||
@ -182,6 +222,8 @@ jobs:
|
|||||||
aws-region: ${{ env.DEJO_NODE_AWS_REGION }}
|
aws-region: ${{ env.DEJO_NODE_AWS_REGION }}
|
||||||
|
|
||||||
- name: Deploy API
|
- name: Deploy API
|
||||||
|
id: deploy_api
|
||||||
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.DEJO_NODE_KUBE_CONFIG_DATA_DEV }}" | base64 -d > kubeconfig
|
echo "${{ secrets.DEJO_NODE_KUBE_CONFIG_DATA_DEV }}" | base64 -d > kubeconfig
|
||||||
export KUBECONFIG=$PWD/kubeconfig
|
export KUBECONFIG=$PWD/kubeconfig
|
||||||
@ -189,24 +231,21 @@ jobs:
|
|||||||
${{ env.KUBE_DEPLOY_NAME }}="${{ secrets.DEV_DEJO_AWS_ECR_REGISTRY }}/${{ env.AWS_ECR_REPOSITORY }}:${{ env.sha_short }}" \
|
${{ env.KUBE_DEPLOY_NAME }}="${{ secrets.DEV_DEJO_AWS_ECR_REGISTRY }}/${{ env.AWS_ECR_REPOSITORY }}:${{ env.sha_short }}" \
|
||||||
--record -n "${KUBE_NAMESPACE}"
|
--record -n "${KUBE_NAMESPACE}"
|
||||||
|
|
||||||
- name: Verify Rollout
|
- name: Discord | Notify Error (Deploy)
|
||||||
run: |
|
if: steps.deploy_api.outcome == 'failure' && env.DISABLE_DISCORD_NOTIFY != 'true'
|
||||||
echo "${{ secrets.DEJO_NODE_KUBE_CONFIG_DATA_DEV }}" | base64 -d > kubeconfig
|
|
||||||
export KUBECONFIG=$PWD/kubeconfig
|
|
||||||
kubectl rollout status deployment/${{ env.KUBE_DEPLOY_NAME }} -n "${KUBE_NAMESPACE}"
|
|
||||||
|
|
||||||
- name: Discord | Notify Error
|
|
||||||
if: ${{ failure() && env.DISABLE_DISCORD_NOTIFY != 'true' }}
|
|
||||||
run: |
|
run: |
|
||||||
curl -X POST -H "Content-Type: application/json" \
|
curl -X POST -H "Content-Type: application/json" \
|
||||||
-d '{"content":":x: Erro durante o deploy! Veja logs."}' \
|
-d '{"content":":x: Erro durante o deploy! Veja logs."}' \
|
||||||
"${{ env.DISCORD_WEBHOOK }}"
|
"${DISCORD_WEBHOOK}"
|
||||||
exit 1
|
|
||||||
|
|
||||||
- name: Discord | Notify Success
|
- name: Fail job if deploy_api failed
|
||||||
if: ${{ success() && env.DISABLE_DISCORD_NOTIFY != 'true' }}
|
if: steps.deploy_api.outcome == 'failure'
|
||||||
|
run: exit 1
|
||||||
|
|
||||||
|
- name: Discord | Notify Success (Deploy)
|
||||||
|
if: steps.deploy_api.outcome == 'success' && env.DISABLE_DISCORD_NOTIFY != 'true'
|
||||||
run: |
|
run: |
|
||||||
curl -X POST -H "Content-Type: application/json" \
|
curl -X POST -H "Content-Type: application/json" \
|
||||||
-d '{"content":":white_check_mark: Deploy concluído com sucesso! :rocket:"}' \
|
-d '{"content":":white_check_mark: Deploy concluído com sucesso! :rocket:"}' \
|
||||||
"${{ env.DISCORD_WEBHOOK }}"
|
"${DISCORD_WEBHOOK}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user