Skip to content

Commit a42f0bd

Browse files
committed
add inputs for referencing
1 parent 77fc0bb commit a42f0bd

File tree

1 file changed

+39
-16
lines changed

1 file changed

+39
-16
lines changed

.github/workflows/release-post-merge.yml

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
name: Post-Merge Release Actions
22

33
on:
4-
pull_request:
5-
types: [closed]
6-
branches:
7-
- 'main'
4+
workflow_call:
5+
inputs:
6+
base_branch:
7+
type: string
8+
description: "The base branch to check for merged PRs"
9+
required: false
10+
default: "main"
11+
develop_branch:
12+
type: string
13+
description: "The branch to merge into"
14+
required: false
15+
default: "develop"
16+
pr_title:
17+
type: string
18+
description: "The title of the merged pull request"
19+
required: true
20+
pr_number:
21+
type: string
22+
description: "The number of the merged pull request"
23+
required: true
24+
repository_owner:
25+
type: string
26+
description: "The owner of the repository"
27+
required: true
28+
repository_name:
29+
type: string
30+
description: "The name of the repository"
31+
required: true
32+
833

934
permissions:
1035
contents: write
@@ -13,11 +38,9 @@ permissions:
1338
env:
1439
GITHUB_USER: "datavisyn-bot"
1540
GITHUB_TOKEN: ${{ secrets.DATAVISYN_BOT_REPO_TOKEN }}
16-
PR_TITLE: ${{ github.event.pull_request.title }}
1741

1842
jobs:
1943
post_release:
20-
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.title, 'Release') }}
2144
runs-on: ubuntu-22.04
2245
steps:
2346
- name: Checkout Repository
@@ -28,7 +51,7 @@ jobs:
2851

2952
- name: Create and Push Tag
3053
run: |
31-
TAG_NAME="v$(echo "$PR_TITLE" | awk '{print $2}')"
54+
TAG_NAME="v$(echo "${{ inputs.pr_title }}" | awk '{print $2}')"
3255
git tag "$TAG_NAME"
3356
git push origin "$TAG_NAME"
3457
@@ -38,23 +61,23 @@ jobs:
3861
echo "Fetching PR body for release notes..."
3962
PR_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
4063
-H "Accept: application/vnd.github.v3+json" \
41-
https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls/${{ github.event.pull_request.number }})
64+
https://api.github.com/repos/${{ inputs.repository_owner }}/${{ inputs.repository_name }}/pulls/${{ inputs.pr_number }})
4265
4366
PR_BODY=$(echo "$PR_RESPONSE" | jq -r '.body')
4467
echo "$PR_BODY" > pr_release_notes.txt
4568
4669
- name: Create GitHub Release
4770
run: |
48-
TAG_NAME="v$(echo "$PR_TITLE" | awk '{print $2}')"
71+
TAG_NAME="v$(echo "${{ inputs.pr_title }}" | awk '{print $2}')"
4972
RELEASE_NOTES=$(cat pr_release_notes.txt)
5073
5174
RESPONSE=$(curl -s -o response.json -w "%{http_code}" -X POST \
5275
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
5376
-H "Accept: application/vnd.github.v3+json" \
54-
https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/releases \
77+
https://api.github.com/repos/${{ inputs.repository_owner }}/${{ inputs.repository_name }}/releases \
5578
-d "$(jq -n \
5679
--arg tag_name "$TAG_NAME" \
57-
--arg target_commitish "main" \
80+
--arg target_commitish "${{ inputs.base_branch }}" \
5881
--arg name "$TAG_NAME" \
5982
--arg body "$RELEASE_NOTES" \
6083
'{tag_name: $tag_name, target_commitish: $target_commitish, name: $name, body: $body, draft: false, prerelease: false}')")
@@ -72,10 +95,10 @@ jobs:
7295
run: |
7396
git config user.name "$GITHUB_ACTOR"
7497
git config user.email "<>"
75-
git checkout develop
76-
git fetch origin main
77-
git merge origin/main
78-
git push origin develop
98+
git checkout ${{ inputs.develop_branch }}
99+
git fetch origin ${{ inputs.base_branch }}
100+
git merge origin/${{ inputs.base_branch }}
101+
git push origin ${{ inputs.develop_branch }}
79102
80103
- name: Update Package Version for Next Development Cycle
81104
run: |
@@ -85,4 +108,4 @@ jobs:
85108
86109
git add package.json
87110
git commit -m "chore: prepare next dev release"
88-
git push origin develop
111+
git push origin ${{ inputs.develop_branch }}

0 commit comments

Comments
 (0)