Skip to content

Commit b31e303

Browse files
authored
Add workflow to recreate staging branch when it doesn't exist (#73)
2 parents c35e9cd + f7c5e69 commit b31e303

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Recreate Staging Branch
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
recreate-staging:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
21+
- name: Check if staging branch exists
22+
id: check-staging
23+
run: |
24+
if git ls-remote --heads origin staging | grep -q staging; then
25+
echo "exists=true" >> $GITHUB_OUTPUT
26+
else
27+
echo "exists=false" >> $GITHUB_OUTPUT
28+
fi
29+
30+
- name: Recreate staging branch
31+
if: steps.check-staging.outputs.exists == 'false'
32+
run: |
33+
git config user.name "github-actions[bot]"
34+
git config user.email "github-actions[bot]@users.noreply.github.com"
35+
git checkout -b staging
36+
git push origin staging

0 commit comments

Comments
 (0)