-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (46 loc) · 2.39 KB
/
Copy pathgitflow-workflow.yml
File metadata and controls
53 lines (46 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: GitFlow Workflow
on:
pull_request:
types: [closed]
branches: [develop, main]
jobs:
delete-branch:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' && (startsWith(github.event.pull_request.head.ref, 'feature/') || startsWith(github.event.pull_request.head.ref, 'bugfix/') || startsWith(github.event.pull_request.head.ref, 'refactor/'))
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Delete merged feature/bugfix branch
env:
GH_TOKEN: ${{ github.token }}
run: gh api -X DELETE repos/${{ github.repository }}/git/refs/heads/${{ github.event.pull_request.head.ref }} || echo "Branch already deleted or not found"
sync-main-to-develop:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && (startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix/'))
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Git identity
run: |
git config user.name "SassyNic-git-flow[bot]"
git config user.email "SassyNic@bot.github.com"
- name: Fetch all branches
run: git fetch --all
- name: Merge release/ or hotfix/ into develop
run: |
if [[ "${{ github.event.pull_request.head.ref }}" == release/* || "${{ github.event.pull_request.head.ref }}" == hotfix/* ]]; then
git checkout develop
git merge origin/${{ github.event.pull_request.head.ref }} --no-ff --allow-unrelated-histories -m "chore(git-flow): merge ${{ github.event.pull_request.head.ref }} into develop [auto]"
git push origin develop
else
git checkout develop
git merge origin/main --no-ff --allow-unrelated-histories -m "chore(git-flow): sync main into develop [auto]"
git push origin develop
fi
- name: Delete release/hotfix branch
if: startsWith(github.event.pull_request.head.ref, 'release/') || startsWith(github.event.pull_request.head.ref, 'hotfix/')
env:
GH_TOKEN: ${{ github.token }}
run: gh api -X DELETE repos/${{ github.repository }}/git/refs/heads/${{ github.event.pull_request.head.ref }} || echo "Branch already deleted or not found"