Skip to content

BE CD for Prod

BE CD for Prod #75

Workflow file for this run

name: BE CD for Prod
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- backend/**
jobs:
build:
uses: ./.github/workflows/build.yml
with:
profile: prod
secrets:
secret_yml: ${{ secrets.PROD_SECRET_YML }}
deploy-a:
needs: [ build ]
uses: ./.github/workflows/blue-green.yml
with:
self_hosted_runner: prod-c # todo a
artifact_name: ${{ needs.build.outputs.artifact_name }}
jar_name: ${{ needs.build.outputs.jar_name }}
profile: prod
app_path: ~/app
deploy-b:
needs: [ build ]
uses: ./.github/workflows/blue-green.yml
with:
self_hosted_runner: prod-d # todo b
artifact_name: ${{ needs.build.outputs.artifact_name }}
jar_name: ${{ needs.build.outputs.jar_name }}
profile: prod
app_path: ~/app
detect-deploy-failure:
needs: [ deploy-a, deploy-b ]
if: failure() && (needs.deploy-a.result == 'failure' || needs.deploy-b.result == 'failure')
runs-on: ubuntu-latest
outputs:
green_port_a: ${{ needs.deploy-a.outputs.green_port }}
green_port_b: ${{ needs.deploy-b.outputs.green_port }}
steps:
- name: Send notification to Discord # todo
run: echo "테스트입니다"
rollback-a:
needs: [ detect-deploy-failure ]
if: failure() && needs.detect-deploy-failure.result == 'success'
uses: ./.github/workflows/shutdown.yml
with:
self_hosted_runner: prod-c # todo a
port: ${{ needs.detect-deploy-failure.outputs.green_port_a }}
rollback-b:
needs: [ detect-deploy-failure ]
if: failure() && needs.detect-deploy-failure.result == 'success'
uses: ./.github/workflows/shutdown.yml
with:
self_hosted_runner: prod-d # todo b
port: ${{ needs.detect-deploy-failure.outputs.green_port_b }}
configure-nginx-a:
needs: [ deploy-a, deploy-b ]
uses: ./.github/workflows/nginx-port-forwarding.yml
with:
self_hosted_runner: prod-c # todo a
app_path: ~/app
old_port: ${{ needs.deploy-a.outputs.blue_port }}
new_port: ${{ needs.deploy-a.outputs.green_port }}
configure-nginx-b:
needs: [ deploy-a, deploy-b ]
uses: ./.github/workflows/nginx-port-forwarding.yml
with:
self_hosted_runner: prod-d # todo b
app_path: ~/app
old_port: ${{ needs.deploy-b.outputs.blue_port }}
new_port: ${{ needs.deploy-b.outputs.green_port }}
test: true
detect-configure-nginx-faliure:
needs: [ configure-nginx-a, configure-nginx-b ]
if: failure() && (needs.configure-nginx-a.result == 'failure' || needs.configure-nginx-b.result == 'failure')
runs-on: ubuntu-latest
outputs:
old_port_a: ${{ needs.configure-nginx-a.outputs.old_port }}
new_port_a: ${{ needs.configure-nginx-a.outputs.new_port }}
old_port_b: ${{ needs.configure-nginx-b.outputs.old_port }}
new_port_b: ${{ needs.configure-nginx-b.outputs.new_port }}
steps:
- name: Send notification to Discord # todo
run: echo "테스트입니다"
rollback-nginx-a:
needs: [ detect-configure-nginx-faliure ]
if: failure() && needs.detect-configure-nginx-faliure.result == 'success'
uses: ./.github/workflows/nginx-port-forwarding.yml
with:
self_hosted_runner: prod-c # todo a
app_path: ~/app
old_port: ${{ needs.detect-configure-nginx-faliure.outputs.new_port_a }}
new_port: ${{ needs.detect-configure-nginx-faliure.outputs.old_port_a }}
old_shutdown: true
rollback-nginx-b:
needs: [ detect-configure-nginx-faliure ]
if: failure() && needs.detect-configure-nginx-faliure.result == 'success'
uses: ./.github/workflows/nginx-port-forwarding.yml
with:
self_hosted_runner: prod-d # todo b
app_path: ~/app
old_port: ${{ needs.detect-configure-nginx-faliure.outputs.new_port_b }}
new_port: ${{ needs.detect-configure-nginx-faliure.outputs.old_port_b }}
old_shutdown: true
blue-shutdown-a:
needs: [ configure-nginx-a ]
uses: ./.github/workflows/shutdown.yml
with:
self_hosted_runner: prod-c # todo a
port: ${{ needs.configure-nginx-a.outputs.old_port }}
blue-shutdown-b:
needs: [ configure-nginx-b ]
uses: ./.github/workflows/shutdown.yml
with:
self_hosted_runner: prod-d # todo b
port: ${{ needs.configure-nginx-b.outputs.old_port }}
# on-failure:
# needs: [ blue-down ] # 알림
# if: ${{ needs.blue-down.result == 'failure' }}
# steps:
# - name: Send Notification
# run: echo "테스트입니다"