fix: ensure we have latest remote branch data #99
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cd-stage | |
concurrency: | |
group: stage | |
cancel-in-progress: true | |
on: | |
push: | |
branches: | |
- stage | |
jobs: | |
deploy_stage: | |
runs-on: ubuntu-latest | |
env: | |
ENV: "stage" | |
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@v4 | |
- 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@v4.1.0 | |
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 Stage | |
run: gcloud app deploy app.yaml --quiet --project zesty-stage | |
deploy_failed_notification_to_slack: | |
runs-on: ubuntu-latest | |
if: ${{ failure() }} | |
needs: [deploy_stage] | |
steps: | |
- name: Failed Deploy Notification To Slack | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: code-deploy | |
SLACK_COLOR: "#FF2A08" | |
SLACK_ICON: https://brand.zesty.io/zesty-io-logo.svg | |
SLACK_MESSAGE: "PR merge by ${{ github.actor }} failed to deploy." | |
SLACK_TITLE: "FAILED: Stage Deployment for manager-ui" | |
SLACK_USERNAME: Deploy Bot | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
deploy_success_notification_to_slack: | |
runs-on: ubuntu-latest | |
if: ${{ success() }} | |
needs: [deploy_stage] | |
steps: | |
- name: Success Deploy Notification To Slack | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: code-deploy | |
SLACK_COLOR: "#75BF43" | |
SLACK_ICON: https://brand.zesty.io/zesty-io-logo.svg | |
# SLACK_MESSAGE: "PR merge by ${{ github.actor }} has been deployed to stage." | |
SLACK_TITLE: "STAGE:manager-ui" | |
SLACK_USERNAME: Deploy Bot | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
create_beta_pr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Retrive latest branches | |
uses: git fetch origin | |
- name: Get origin branch list | |
run: | | |
echo "origin_branch_list=$(git branch -r --list origin/beta)" >> "$GITHUB_ENV" | |
- name: Ensure origin/beta branch exists | |
if: env.origin_branch_list != 'origin/beta' | |
run: git checkout stage && git switch --create beta && git push -u origin beta | |
- name: Check if PR exists | |
id: check | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
prs=$(gh pr list \ | |
--repo "$GITHUB_REPOSITORY" \ | |
--head 'stage' \ | |
--base 'beta' \ | |
--json title \ | |
--jq 'length') | |
if ((prs > 0)); then | |
echo "skip=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Create Beta Release | |
if: "!steps.check.outputs.skip" | |
run: gh pr create -B beta -H stage --title 'Beta Release' --body 'Created by Github action' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |