-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-tag-version-v0.0.21
- Loading branch information
Showing
7 changed files
with
218 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: Single PR for Closed Milestone PRs | ||
|
||
on: | ||
workflow_dispatch: # Manual trigger | ||
inputs: | ||
milestone: | ||
description: 'Milestone name to collect closed PRs from' | ||
required: true | ||
default: 'v3.8.2' # Default milestone set to v3.8.2 | ||
target_branch: | ||
description: 'Target branch to merge the consolidated PR' | ||
required: true | ||
default: 'pre-release-v3.8.2' # Default target branch with pre-release-v*.* format | ||
schedule: | ||
- cron: '0 0 * * 0' # Scheduled to run every Sunday at 00:00 UTC | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
cherry_pick_closed_milestone_prs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Step 1: Checkout the repository code | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
# Step 2: Set up Git user details for making commits | ||
- name: Setup Git | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
# Step 3: Install GitHub CLI to interact with milestones and PRs | ||
- name: Install GitHub CLI | ||
run: sudo apt install gh | ||
|
||
# Step 4: Authenticate GitHub CLI using GITHUB_TOKEN | ||
- name: Authenticate GitHub CLI | ||
run: echo "${{ env.GITHUB_TOKEN }}" | gh auth login --with-token | ||
|
||
# Step 5: Fetch closed PRs from the specified milestone | ||
- name: Fetch Closed PRs from Milestone | ||
id: fetch_prs | ||
run: | | ||
milestone="${{ github.event.inputs.milestone }}" | ||
prs=$(gh pr list --search "milestone:$milestone is:closed" --json number,headRefName,mergeCommit) | ||
echo "::set-output name=prs::$prs" | ||
# Step 6: Create a new branch from main, cherry-pick PRs, and push to remote | ||
- name: Create and Cherry-pick Branch | ||
if: ${{ steps.fetch_prs.outputs.prs != '[]' }} | ||
run: | | ||
target_branch="${{ github.event.inputs.target_branch }}" | ||
cherry_pick_branch="milestone-cherry-pick-$(date +%Y%m%d%H%M%S)" | ||
# Switch to main branch, pull latest changes, then create a new cherry-pick branch | ||
git checkout main | ||
git pull origin main | ||
git checkout -b $cherry_pick_branch | ||
# Iterate over closed PRs in the milestone and cherry-pick each merge commit | ||
echo "${{ steps.fetch_prs.outputs.prs }}" | jq -c '.[]' | while read -r pr; do | ||
pr_number=$(echo "$pr" | jq '.number') | ||
merge_commit=$(echo "$pr" | jq -r '.mergeCommit') | ||
if [ "$merge_commit" != "null" ]; then | ||
# Check if the merge commit is already in the target branch | ||
if git merge-base --is-ancestor $merge_commit $target_branch; then | ||
echo "Skipping PR #$pr_number - Commit $merge_commit already in $target_branch" | ||
else | ||
echo "Cherry-picking PR #$pr_number with commit $merge_commit" | ||
git cherry-pick $merge_commit || git cherry-pick --abort | ||
fi | ||
else | ||
echo "Skipping PR #$pr_number as it does not have a merge commit." | ||
fi | ||
done | ||
# Push the cherry-pick branch to the remote repository | ||
git push origin $cherry_pick_branch | ||
# Step 7: Create a single pull request to merge the cherry-pick branch into the target branch | ||
- name: Create Pull Request to Target Branch | ||
if: steps.fetch_prs.outputs.prs != "[]" | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: $cherry_pick_branch | ||
base: ${{ github.event.inputs.target_branch }} | ||
title: "Consolidated Closed Milestone PRs for ${{ github.event.inputs.target_branch }}" | ||
body: "This PR includes all cherry-picked changes from closed PRs in milestone '${{ github.event.inputs.milestone }}' to ${{ github.event.inputs.target_branch }}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Assign Milestone to PR | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, reopened] | ||
|
||
jobs: | ||
assign-milestone: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
STABLE_VERSION_MILESTONE: v3.8 | ||
FEATURE_VERSION_MILESTONE: v3.8.2 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set milestone based on PR title | ||
id: set-milestone | ||
run: | | ||
if [[ "${{ github.event.pull_request.title }}" == fix:* ]]; then | ||
echo "::set-output name=milestone::${{ env.STABLE_VERSION_MILESTONE }}" | ||
else | ||
echo "::set-output name=milestone::${{ env.FEATURE_VERSION_MILESTONE }}" | ||
fi | ||
shell: bash | ||
|
||
- name: Assign milestone to PR | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const pr = context.payload.pull_request; | ||
const milestoneTitle = '${{ steps.set-milestone.outputs.milestone }}'; | ||
const { data: milestones } = await github.rest.issues.listMilestones({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
const milestone = milestones.find(m => m.title === milestoneTitle); | ||
if (milestone) { | ||
await github.rest.issues.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: pr.number, | ||
milestone: milestone.number | ||
}); | ||
console.log(`Assigned milestone "${milestone.title}" to PR #${pr.number}`); | ||
} else { | ||
console.log(`Milestone "${milestoneTitle}" not found.`); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# name: Upgrade version by tag | ||
|
||
# permissions: | ||
# contents: write | ||
# pull-requests: write | ||
|
||
# on: | ||
# push: | ||
# tags: | ||
# - 'v[0-9]+.[0-9]+.[0-9]+' | ||
|
||
# jobs: | ||
# upgrade_version: | ||
# runs-on: ubuntu-latest | ||
# env: | ||
# TAG_VERSION: ${{ github.ref_name }} | ||
# BRANCH_NAME: update-tag-version-${{ github.ref_name }} | ||
# steps: | ||
# # Step 1: Checkout the original repository's code | ||
# - name: Checkout code | ||
# uses: actions/checkout@v4 | ||
# with: | ||
# # repository: openimsdk/actions-test | ||
# fetch-depth: 0 | ||
|
||
# # Step 2: Set up Git with official account | ||
# - name: Set up Git | ||
# run: | | ||
# git config user.name "github-actions[bot]" | ||
# git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
||
# # # Step 3: Create a new branch for version update | ||
# # - name: Create new branch for version update | ||
# # run: | | ||
# # git checkout -b ${{ env.BRANCH_NAME }} | ||
|
||
# # Step 4: Update version file | ||
# - name: Update version file | ||
# run: | | ||
# echo "${{ env.TAG_VERSION }}" > version/version | ||
|
||
|
||
# # Step 5: Create a Pull Request from the new branch to the original repository | ||
# - name: Create Pull Request | ||
# id: create_pr | ||
# uses: peter-evans/[email protected] | ||
# with: | ||
# branch-token: ${{ secrets.GITHUB_TOKEN }} | ||
# token: ${{ secrets.GITHUB_TOKEN }} | ||
# # token: ${{ secrets.BOT_TOKEN }} | ||
# commit-message: "Update version to ${{ env.TAG_VERSION }}" | ||
# branch: ${{ env.BRANCH_NAME }} | ||
# delete-branch: true | ||
# base: main | ||
# title: "Update version to ${{ env.TAG_VERSION }}" | ||
# body: "This PR updates the version file to the new tag version ${{ env.TAG_VERSION }}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.