Skip to content

Commit 0ea227d

Browse files
authored
chore: Add source branch input to the release workflow, tag release, sync to private repo (#20121)
1 parent 13bdaf9 commit 0ea227d

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

Diff for: .github/workflows/minor-release.yml

+34-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
name: Minor Release
1+
name: Release snapshot (creates a snapshot from the develop branch or from the input-provided source)
22

33
on:
44
workflow_dispatch:
55
inputs:
6+
source:
7+
description: 'Source to release from (e.g., release-2211.20.0). By default, the develop branch is used.'
8+
required: false
69
version:
710
description: 'Release version (e.g., 2211.20.0 or 2211.20.0-1)'
8-
required: false
11+
required: true
912

1013
jobs:
1114
release:
@@ -14,7 +17,7 @@ jobs:
1417
- name: Checkout code
1518
uses: actions/checkout@v4
1619
with:
17-
ref: develop
20+
ref: ${{ github.event.inputs.source || 'develop' }}
1821

1922
- name: Configure Git
2023
run: |
@@ -96,4 +99,31 @@ jobs:
9699
git add .
97100
git commit -m "Release ${{ env.version }}"
98101
git push origin "${{ env.RELEASE_BRANCH }}"
99-
102+
103+
- name: Tag the release
104+
run: |
105+
git fetch origin "${{ env.RELEASE_BRANCH }}"
106+
git checkout "${{ env.RELEASE_BRANCH }}"
107+
108+
TAG="${{ env.version }}"
109+
110+
# Check if tag already exists
111+
if git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
112+
echo "Tag $TAG already exists. Skipping creation."
113+
else
114+
git tag -a "$TAG" -m "$TAG"
115+
git push origin "$TAG"
116+
echo "Created and pushed tag: $TAG"
117+
fi
118+
119+
- name: Sync branch to a private repo
120+
env:
121+
GH_TOKEN: ${{ secrets.GH_PR_TOKEN }}
122+
run: |
123+
echo "Triggering repo-sync.yml with branch: ${{ env.RELEASE_BRANCH }}"
124+
125+
curl -X POST \
126+
-H "Accept: application/vnd.github+json" \
127+
-H "Authorization: Bearer $GH_TOKEN" \
128+
https://api.github.com/repos/${{ github.repository }}/actions/workflows/repo-sync.yml/dispatches \
129+
-d "{\"ref\":\"${{ env.RELEASE_BRANCH }}\",\"inputs\":{\"branch_to_sync\":\"${{ env.RELEASE_BRANCH }}\"}}"

0 commit comments

Comments
 (0)