Skip to content

Commit

Permalink
fix: switch to concurrency groups and release-please in CD
Browse files Browse the repository at this point in the history
  • Loading branch information
shrunyan committed Mar 27, 2024
1 parent c959f6c commit 72b333c
Showing 1 changed file with 43 additions and 32 deletions.
75 changes: 43 additions & 32 deletions .github/workflows/cd-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
name: cd-dev

concurrency:
group: dev
cancel-in-progress: true

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

jobs:
deploy_dev:
runs-on: ubuntu-latest
env:
ENV: "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
uses: actions/checkout@v4
- name: Auth with Gcloud
uses: google-github-actions/auth@v2
with:
Expand Down Expand Up @@ -79,30 +76,44 @@ jobs:
SLACK_USERNAME: Deploy Bot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

create_stage_pr:
release-please:
runs-on: ubuntu-latest
needs: [deploy_dev]
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- uses: google-github-actions/release-please-action@v4
with:
# this assumes that you have created a personal access token
# (PAT) and configured it as a GitHub action secret named
# `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
token: ${{ secrets.GITHUB_TOKEN }}
# this is a built-in strategy in release-please, see "Action Inputs"
# for more options
release-type: node
target-branch: stage

- name: Check if PR exists
id: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
prs=$(gh pr list \
--repo "$GITHUB_REPOSITORY" \
--head 'dev' \
--base 'stage' \
--json title \
--jq 'length')
if ((prs > 0)); then
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
# create_stage_pr:
# runs-on: ubuntu-latest
# needs: [deploy_dev]
# steps:
# - name: Checkout Repo
# uses: actions/checkout@v2

- name: Create Stage Release
if: "!steps.check.outputs.skip"
run: gh pr create -B stage -H dev --title 'Stage Release' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Check if PR exists
# id: check
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# prs=$(gh pr list \
# --repo "$GITHUB_REPOSITORY" \
# --head 'dev' \
# --base 'stage' \
# --json title \
# --jq 'length')
# if ((prs > 0)); then
# echo "skip=true" >> "$GITHUB_OUTPUT"
# fi

# - name: Create Stage Release
# if: "!steps.check.outputs.skip"
# run: gh pr create -B stage -H dev --title 'Stage Release' --body 'Created by Github action'
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 72b333c

Please sign in to comment.