Template
Add .gitea/workflows/create_dev_branch.yml
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
name: Create Dev Branch
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
create-dev:
|
||||||
|
name: Create Dev Branch
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.run_number == 1
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.PAT_TOKEN }}
|
||||||
|
|
||||||
|
- name: Check if dev branch exists
|
||||||
|
id: check_branch
|
||||||
|
run: |
|
||||||
|
if git ls-remote --heads origin dev | grep -q "refs/heads/dev"; then
|
||||||
|
echo "dev_exists=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "Dev branch already exists"
|
||||||
|
else
|
||||||
|
echo "dev_exists=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "Dev branch does not exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Create dev branch
|
||||||
|
if: steps.check_branch.outputs.dev_exists == 'false'
|
||||||
|
run: |
|
||||||
|
git config --local user.email "actions@gitea.local"
|
||||||
|
git config --local user.name "Gitea Actions Bot"
|
||||||
|
|
||||||
|
git checkout -b dev
|
||||||
|
git push origin dev
|
||||||
|
|
||||||
|
echo "Dev branch created successfully"
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
run: |
|
||||||
|
echo "## Dev Branch Status" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
if [ "${{ steps.check_branch.outputs.dev_exists }}" = "true" ]; then
|
||||||
|
echo "Dev branch already exists. No action taken." >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "Dev branch created successfully." >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user