diff --git a/.github/workflows/recreate-staging.yaml b/.github/workflows/recreate-staging.yaml new file mode 100644 index 00000000..de73e9ac --- /dev/null +++ b/.github/workflows/recreate-staging.yaml @@ -0,0 +1,36 @@ +name: Recreate Staging Branch + +on: + push: + branches: + - main + +permissions: + contents: write + +jobs: + recreate-staging: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if staging branch exists + id: check-staging + run: | + if git ls-remote --heads origin staging | grep -q staging; then + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + + - name: Recreate staging branch + if: steps.check-staging.outputs.exists == 'false' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git checkout -b staging + git push origin staging