Skip to content

Commit f82d85f

Browse files
authored
Merge pull request #148 from ansidev/feature/refactor-gitflow-workflows
Refactor gitflow workflows
2 parents 5b63a63 + 13b58ec commit f82d85f

6 files changed

+132
-212
lines changed

.github/workflows/auto_merge_release_hotfix_into_develop.yaml

-40
This file was deleted.
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: create_release_pr
2+
3+
on:
4+
push:
5+
branches:
6+
- "release/**"
7+
- "hotfix/**"
8+
9+
jobs:
10+
create_release_pr:
11+
name: Create release pull request
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
# only create draft pull requests on
16+
# pushing to branches 'release/' or 'hotfix/'
17+
if: |
18+
startsWith(github.ref_name, 'release/') ||
19+
startsWith(github.ref_name, 'hotfix/')
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
with:
25+
ref: ${{ github.ref_name }}
26+
token: ${{ secrets.GH_TOKEN }}
27+
# needed by "gh pr create"
28+
fetch-depth: 0
29+
30+
- name: Set release type as release
31+
if: startsWith(github.ref_name, 'release/')
32+
run: echo "RELEASE_TYPE=release" >> "$GITHUB_ENV"
33+
34+
- name: Set release type as hotfix
35+
if: startsWith(github.ref_name, 'hotfix/')
36+
run: echo "RELEASE_TYPE=hotfix" >> "$GITHUB_ENV"
37+
38+
- name: Create release pull request
39+
uses: ghacts/gitflow/create-release-pr@main
40+
with:
41+
token: ${{ secrets.GH_TOKEN }}
42+
release-type: ${{ env.RELEASE_TYPE }}
43+
release-branch-prefix: '${{ env.RELEASE_TYPE }}/'

.github/workflows/draft_release_hotfix_pr.yaml

-86
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: merge_release_into_develop
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
branches:
8+
- develop
9+
10+
jobs:
11+
merge_release_into_develop:
12+
name: Merge release into develop
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
# only merge pull requests that begin with 'release/' or 'hotfix/'
17+
if: |
18+
startsWith(github.head_ref, 'release/') ||
19+
startsWith(github.head_ref, 'hotfix/')
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
with:
25+
ref: ${{ github.head_ref }}
26+
token: ${{ secrets.GH_TOKEN }}
27+
# needed by "gh pr create"
28+
fetch-depth: 0
29+
30+
- name: Merge ${{ github.head_ref }} into develop
31+
uses: ghacts/gitflow/merge-release-into-develop@main
32+
with:
33+
token: ${{ secrets.GH_TOKEN }}
34+
release-branch: ${{ github.head_ref }}
35+
develop-branch: develop
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: publish_release
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
branches:
8+
- main
9+
10+
env:
11+
VERSION_TAG_PREFIX: "v"
12+
13+
jobs:
14+
release:
15+
name: Publish release
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
# only merge pull requests that begin with 'release/' or 'hotfix/'
20+
if: github.event.pull_request.merged == true &&
21+
(startsWith(github.head_ref, 'release/') || startsWith(github.head_ref, 'hotfix/'))
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
with:
27+
ref: ${{ github.head_ref }}
28+
token: ${{ secrets.GH_TOKEN }}
29+
# needed by "gh pr create"
30+
fetch-depth: 0
31+
32+
- name: Set release type as release
33+
if: startsWith(github.head_ref, 'release/')
34+
run: echo "RELEASE_TYPE=release" >> "$GITHUB_ENV"
35+
36+
- name: Set release type as hotfix
37+
if: startsWith(github.head_ref, 'hotfix/')
38+
run: echo "RELEASE_TYPE=hotfix" >> "$GITHUB_ENV"
39+
40+
- name: Extract version from release branch
41+
env:
42+
BRANCH_NAME: ${{ github.head_ref }}
43+
BRANCH_PREFIX: '${{ env.RELEASE_TYPE }}/'
44+
run: |
45+
RELEASE_VERSION=${BRANCH_NAME#${BRANCH_PREFIX}}
46+
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
47+
48+
- name: Publish release
49+
uses: ghacts/gitflow/publish-release@main
50+
with:
51+
token: ${{ secrets.GH_TOKEN }}
52+
release-type: ${{ env.RELEASE_TYPE }}
53+
release-branch-prefix: '${{ env.RELEASE_TYPE }}/'
54+
notes-file: '.changes/${{ env.VERSION_TAG_PREFIX }}${{ env.RELEASE_VERSION }}.md'

.github/workflows/release.yaml

-86
This file was deleted.

0 commit comments

Comments
 (0)