Skip to content

Commit

Permalink
fix: split cd by environment
Browse files Browse the repository at this point in the history
  • Loading branch information
shrunyan committed Mar 19, 2024
1 parent 0cbe5ae commit cc06e02
Show file tree
Hide file tree
Showing 3 changed files with 272 additions and 81 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/cd-beta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# name: cd-beta

# on:
# # Uncomment to work on CD in development mode.
# # pull_request:
# # branches: [ master ]
# push:
# branches:
# - beta

# jobs:
# deploy_to_beta:
# runs-on: ubuntu-latest
# env:
# ENV: "beta"

# steps:
# # This Clean step simply checks if there's already a workflow running from the last
# # commit and cancels it if there is. This helps us save on cloud cost in the long run.
# # See https://github.com/rokroskar/workflow-run-cleanup-action for more information.
# - name: Clean
# uses: rokroskar/workflow-run-cleanup-action@v0.2.2
# env:
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# if: "github.ref != 'refs/heads/master'"
# - name: Checkout Repo
# uses: actions/checkout@v2
# - name: Auth with Gcloud
# uses: google-github-actions/auth@v0
# with:
# credentials_json: ${{ secrets.GCP_DEV_SA_KEY }}
# - name: Set up Gcloud SDK
# uses: google-github-actions/setup-gcloud@v0
# with:
# project_id: zesty-dev
# - name: Set up Node
# uses: actions/setup-node@v2
# with:
# node-version: "16.5.0"
# cache: "npm"
# cache-dependency-path: package-lock.json
# - name: Install Dependencies
# run: npm install
# - name: Build
# run: npm run build:dev
# env:
# SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
# - name: Deploy to Dev
# run: gcloud app deploy app.yaml --quiet --project zesty-dev
# - name: Post Successful Dev Deploy Notification To Slack
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_CHANNEL: devops
# SLACK_COLOR: ${{ job.status }}
# SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
# SLACK_MESSAGE: |
# Use :eyes: to signal you have seen this message.
# Use :white_check_mark: to signal you have successfully manually tested the deployed changes.
# Use :x: to signal manual tests on deployed changes were unsuccessful and start a thread under this alert describing your remediation steps.
# SLACK_TITLE: Successfully Deployed manager-ui to Dev
# SLACK_USERNAME: Deploy Bot
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# cancel_workflow_if_beta_deploy_failed:
# runs-on: ubuntu-latest
# if: ${{ failure() }}
# needs:
# - deploy_to_beta
# steps:
# - name: Post Failed Beta Deploy Notification To Slack
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_CHANNEL: devops
# SLACK_COLOR: "#FF0000"
# SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
# SLACK_MESSAGE: "PR merge by ${{ github.actor }} has failed to deploy to beta."
# SLACK_TITLE: Beta Deployment Failed for manager-ui
# SLACK_USERNAME: Deploy Bot
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# - name: Cancel current workflow run
# uses: actions/github-script@v4
# with:
# script: |
# github.actions.cancelWorkflowRun({
# owner: context.repo.owner,
# repo: context.repo.repo,
# run_id: context.runId
# })
# create_stable_pr:
# runs-on: ubuntu-latest
# needs:
# - deploy_to_beta

# steps:
# - name: Create Stable Release PR
# uses: peter-evans/create-pull-request@v6
# with:
# branch: beta
# base: master
# title: master
# # labels:
166 changes: 85 additions & 81 deletions .github/workflows/cd.yaml → .github/workflows/cd-dev-stage.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: cd
name: cd-dev-stage

on:
# Uncomment to work on CD in development mode.
Expand All @@ -7,8 +7,6 @@ on:
push:
branches:
- dev
workflow_dispatch:

jobs:
deploy_to_dev:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -61,13 +59,6 @@ jobs:
SLACK_TITLE: Successfully Deployed manager-ui to Dev
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
branch: dev
base: beta
title: beta
# labels:
cancel_workflow_if_dev_deploy_failed:
runs-on: ubuntu-latest
if: ${{ failure() }}
Expand All @@ -93,76 +84,89 @@ jobs:
repo: context.repo.repo,
run_id: context.runId
})
# create_beta_pr:
# runs-on: ubuntu-latest
# steps:
# deploy_to_stage:
# runs-on: ubuntu-latest
# env:
# ENV: "stage"
# needs:
# - deploy_to_dev
deploy_to_stage:
runs-on: ubuntu-latest
env:
ENV: "stage"
needs:
- deploy_to_dev

# steps:
# # This Clean step simply checks if there's already a workflow running from the last
# # commit and cancels it if there is. This helps us save on cloud cost in the long run.
# # See https://github.com/rokroskar/workflow-run-cleanup-action for more information.
# - name: Clean
# uses: rokroskar/workflow-run-cleanup-action@v0.2.2
# env:
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# if: "github.ref != 'refs/heads/master'"
# - name: Checkout Repo
# uses: actions/checkout@v2
# - name: Auth with Gcloud
# uses: google-github-actions/auth@v0
# with:
# credentials_json: ${{ secrets.GCP_SA_KEY }}
# - name: Set up Gcloud SDK
# uses: google-github-actions/setup-gcloud@v0
# with:
# project_id: zesty-stage
# - name: Set up Node
# uses: actions/setup-node@v2
# with:
# node-version: "16.5.0"
# cache: "npm"
# cache-dependency-path: package-lock.json
# - name: Install Dependencies
# run: npm install
# - name: Build
# run: npm run build:stage
# env:
# SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
# - name: Deploy to Staging
# run: gcloud app deploy app.yaml --quiet --project zesty-stage
# - name: Post Successful Stage Deploy Notification To Slack
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_CHANNEL: devops
# SLACK_COLOR: ${{ job.status }}
# SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
# SLACK_MESSAGE: |
# Use :eyes: to signal you have seen this message.
# Use :white_check_mark: to signal you have successfully manually tested the deployed changes.
# Use :x: to signal manual tests on deployed changes were unsuccessful and start a thread under this alert describing your remediation steps.
# SLACK_TITLE: Successfully Deployed manager-ui to Stage
# SLACK_USERNAME: Deploy Bot
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# post_failed_stage_deploy_notification_to_slack:
# runs-on: ubuntu-latest
# if: ${{ failure() }}
# needs:
# - deploy_to_stage
# steps:
# - name: Post Failed Staging Deploy Notification To Slack
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_CHANNEL: devops
# SLACK_COLOR: "#FF0000"
# SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
# SLACK_MESSAGE: "PR merge by ${{ github.actor }} has failed to deploy to staging."
# SLACK_TITLE: Staging Deployment Failed for manager-ui
# SLACK_USERNAME: Deploy Bot
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
steps:
# This Clean step simply checks if there's already a workflow running from the last
# commit and cancels it if there is. This helps us save on cloud cost in the long run.
# See https://github.com/rokroskar/workflow-run-cleanup-action for more information.
- name: Clean
uses: rokroskar/workflow-run-cleanup-action@v0.2.2
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/master'"
- name: Checkout Repo
uses: actions/checkout@v2
- name: Auth with Gcloud
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Gcloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: zesty-stage
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: "16.5.0"
cache: "npm"
cache-dependency-path: package-lock.json
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build:stage
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Deploy to Staging
run: gcloud app deploy app.yaml --quiet --project zesty-stage
- name: Post Successful Stage Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: devops
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
SLACK_MESSAGE: |
Use :eyes: to signal you have seen this message.
Use :white_check_mark: to signal you have successfully manually tested the deployed changes.
Use :x: to signal manual tests on deployed changes were unsuccessful and start a thread under this alert describing your remediation steps.
SLACK_TITLE: Successfully Deployed manager-ui to Stage
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
post_failed_stage_deploy_notification_to_slack:
runs-on: ubuntu-latest
if: ${{ failure() }}
needs:
- deploy_to_stage
steps:
- name: Post Failed Staging Deploy Notification To Slack
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: devops
SLACK_COLOR: "#FF0000"
SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
SLACK_MESSAGE: "PR merge by ${{ github.actor }} has failed to deploy to staging."
SLACK_TITLE: Staging Deployment Failed for manager-ui
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

create_beta_pr:
runs-on: ubuntu-latest
needs:
- deploy_to_dev
- deploy_to_stage

steps:
- uses: actions/checkout@v4
- name: Create Beta Release PR
uses: peter-evans/create-pull-request@v6
with:
branch: dev
base: beta
title: beta
# labels:
87 changes: 87 additions & 0 deletions .github/workflows/cd-stable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# name: cd-stable

# on:
# # Uncomment to work on CD in development mode.
# # pull_request:
# # branches: [ master ]
# push:
# branches:
# - master

# jobs:
# deploy_to_stable:
# runs-on: ubuntu-latest
# env:
# ENV: "stable"

# steps:
# # This Clean step simply checks if there's already a workflow running from the last
# # commit and cancels it if there is. This helps us save on cloud cost in the long run.
# # See https://github.com/rokroskar/workflow-run-cleanup-action for more information.
# - name: Clean
# uses: rokroskar/workflow-run-cleanup-action@v0.2.2
# env:
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# if: "github.ref != 'refs/heads/master'"
# - name: Checkout Repo
# uses: actions/checkout@v2
# - name: Auth with Gcloud
# uses: google-github-actions/auth@v0
# with:
# credentials_json: ${{ secrets.GCP_DEV_SA_KEY }}
# - name: Set up Gcloud SDK
# uses: google-github-actions/setup-gcloud@v0
# with:
# project_id: zesty-dev
# - name: Set up Node
# uses: actions/setup-node@v2
# with:
# node-version: "16.5.0"
# cache: "npm"
# cache-dependency-path: package-lock.json
# - name: Install Dependencies
# run: npm install
# - name: Build
# run: npm run build:dev
# env:
# SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
# - name: Deploy to Dev
# run: gcloud app deploy app.yaml --quiet --project zesty-dev
# - name: Post Successful Dev Deploy Notification To Slack
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_CHANNEL: devops
# SLACK_COLOR: ${{ job.status }}
# SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
# SLACK_MESSAGE: |
# Use :eyes: to signal you have seen this message.
# Use :white_check_mark: to signal you have successfully manually tested the deployed changes.
# Use :x: to signal manual tests on deployed changes were unsuccessful and start a thread under this alert describing your remediation steps.
# SLACK_TITLE: Successfully Deployed manager-ui to Dev
# SLACK_USERNAME: Deploy Bot
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# cancel_workflow_if_beta_deploy_failed:
# runs-on: ubuntu-latest
# if: ${{ failure() }}
# needs:
# - deploy_to_stable
# steps:
# - name: Post Failed Dev Deploy Notification To Slack
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_CHANNEL: devops
# SLACK_COLOR: "#FF0000"
# SLACK_ICON: https://clipart.world/wp-content/uploads/2021/06/Rocket-Ship-clipart-png.png
# SLACK_MESSAGE: "PR merge by ${{ github.actor }} has failed to deploy to dev."
# SLACK_TITLE: Dev Deployment Failed for manager-ui
# SLACK_USERNAME: Deploy Bot
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# - name: Cancel current workflow run
# uses: actions/github-script@v4
# with:
# script: |
# github.actions.cancelWorkflowRun({
# owner: context.repo.owner,
# repo: context.repo.repo,
# run_id: context.runId
# })

0 comments on commit cc06e02

Please sign in to comment.