Skip to content

Commit 9904da4

Browse files
committed
ci
1 parent 0d58e06 commit 9904da4

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,40 @@ jobs:
1616
with:
1717
fetch-depth: 0
1818

19+
# Generate commit history and calculate suggested merge date
20+
- name: Generate commit history and schedule
21+
id: generate-commits
22+
run: |
23+
# Get the commit history between master and dev
24+
COMMIT_LIST=$(git log --pretty=format:"* %s (%h) by %an" origin/master..origin/dev)
25+
26+
# Handle empty commit list (branches are identical)
27+
if [ -z "$COMMIT_LIST" ]; then
28+
COMMIT_LIST="No new commits - branches may be identical"
29+
fi
30+
31+
# Calculate suggested merge date based on release policy
32+
# By default, suggesting next Monday as merge date - adjust according to your policy
33+
MERGE_DATE=$(date -d "next Monday" +"%A, %B %d, %Y")
34+
35+
# Save commit list to a file (to handle multi-line output)
36+
echo "$COMMIT_LIST" > commit_list.txt
37+
38+
# Create a PR body with the commit list and suggested merge date
39+
echo "PR_BODY<<EOF" >> $GITHUB_ENV
40+
echo "This is an automated PR to promote changes from \`dev\` to \`master\`." >> $GITHUB_ENV
41+
echo "" >> $GITHUB_ENV
42+
echo "## Suggested Merge Schedule" >> $GITHUB_ENV
43+
echo "According to our release policy, this PR is expected to be merged on: **$MERGE_DATE**" >> $GITHUB_ENV
44+
echo "" >> $GITHUB_ENV
45+
echo "## Commits to be merged:" >> $GITHUB_ENV
46+
echo "\`\`\`" >> $GITHUB_ENV
47+
cat commit_list.txt >> $GITHUB_ENV
48+
echo "\`\`\`" >> $GITHUB_ENV
49+
echo "" >> $GITHUB_ENV
50+
echo "Please review the changes carefully before merging." >> $GITHUB_ENV
51+
echo "EOF" >> $GITHUB_ENV
52+
1953
# Use a fixed branch name for the PR
2054
- name: Update dev-to-master branch
2155
run: |
@@ -39,7 +73,7 @@ jobs:
3973
const { repo, owner } = context.repo;
4074
const prBranch = "automated-dev-to-master-branch";
4175
const prTitle = "Promote dev changes to master";
42-
const prBody = "This is an automated PR to promote changes from `dev` to `master`.\n\nPlease review the changes carefully before merging.";
76+
const prBody = process.env.PR_BODY;
4377
4478
// Retry helper function
4579
async function retryOperation(operation, maxRetries = 3, delay = 5000) {
@@ -99,7 +133,7 @@ jobs:
99133
console.log(`PR created: ${result.data.html_url}`);
100134
} catch (error) {
101135
console.log(`All attempts to create PR failed: ${error.message}`);
102-
136+
103137
// As a fallback, output command for manual PR creation
104138
console.log(`To create the PR manually, visit: https://github.com/${owner}/${repo}/compare/master...${prBranch}`);
105139
throw error;

0 commit comments

Comments
 (0)