Skip to content

Commit

Permalink
Workflows (#3037)
Browse files Browse the repository at this point in the history
Fix ensure next promotion branch exists. Seems you can not run shell
commands in if statements.
  • Loading branch information
shrunyan authored Oct 25, 2024
1 parent 672046b commit b0e0dfa
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/cd-beta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Get origin branch list
run: |
echo "origin_branch_list=$(git branch -r --list origin/stable)" >> "$GITHUB_ENV"
- name: Ensure origin/stable branch exists
if: git branch -r --list origin/stable != 'origin/stable'
if: $origin_branch_list != 'origin/stable'
run: git checkout beta && git switch --create stable && git push -u origin stable

- name: Check if PR exists
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/cd-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Get origin branch list
run: |
echo "origin_branch_list=$(git branch -r --list origin/stage)" >> "$GITHUB_ENV"
- name: Ensure origin/stage branch exists
if: git branch -r --list origin/stage != 'origin/stage'
if: $origin_branch_list != 'origin/stage'
run: git checkout dev && git switch --create stage && git push -u origin stage

- name: Check if PR exists
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/cd-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Switch branch to beta
run: git checkout beta
- name: Switch branch to stable
run: git checkout stable
- name: Get commit short hash
id: get_commit
run: echo "hash=$(git rev-parse --short HEAD)"
Expand All @@ -61,9 +61,8 @@ jobs:
- name: Push tag to remote
run: git push origin tag release-${{steps.get_commit.hash}}

# Delete the beta branch after it is merged into beta
# Delete the beta branch after it has been tagged
delete_beta_branch:
# needs: [deploy_stable]
if: github.head_ref == 'beta'
runs-on: ubuntu-latest
steps:
Expand All @@ -74,7 +73,7 @@ jobs:

# Delete the stable branch after it is merged into stable
delete_stable_branch:
needs: [deploy_stable]
needs: [create_release_tag, deploy_stable]
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/cd-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4

- 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: git branch -r --list origin/beta != 'origin/beta'
if: $origin_branch_list != 'origin/beta'
run: git checkout stage && git switch --create beta && git push -u origin beta

- name: Check if PR exists
Expand Down

0 comments on commit b0e0dfa

Please sign in to comment.