-
Notifications
You must be signed in to change notification settings - Fork 123
68 lines (57 loc) · 2.3 KB
/
Copy pathupdate-message-center.yml
File metadata and controls
68 lines (57 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Update Message Center Posts
on:
schedule:
# Runs every Monday at 7:00 AM UTC
- cron: '0 7 * * 1'
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
pull-requests: write
jobs:
update-message-center:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: '22'
- name: Update message center posts
run: node scripts/update-message-center.js
- name: Check for changes
id: changes
run: |
git diff --quiet copilot-agent-strategy/copilot-agents-guide/index.html && echo "changed=false" >> "$GITHUB_OUTPUT" || echo "changed=true" >> "$GITHUB_OUTPUT"
- name: Commit and open PR
if: steps.changes.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.TRAFFIC_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add copilot-agent-strategy/copilot-agents-guide/index.html
DATE=$(date -u +%Y-%m-%d)
BRANCH="message-center/$DATE"
git checkout -b "$BRANCH"
git commit -m "chore: weekly message center posts refresh $DATE"
git push --set-upstream origin "$BRANCH"
# Create PR if one doesn't already exist
existing_pr=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number // empty')
if [ -n "$existing_pr" ]; then
echo "PR #$existing_pr already exists for $BRANCH"
else
gh pr create \
--title "chore: weekly message center posts refresh $DATE" \
--body "Automated weekly message center data update." \
--head "$BRANCH" \
--base master
echo "✅ PR created"
fi
# Enable auto-merge
pr_number=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
if [ -n "$pr_number" ]; then
gh pr merge "$pr_number" --auto --squash \
&& echo "✅ Auto-merge enabled for PR #$pr_number" \
|| echo "::warning::Could not enable auto-merge — check repo settings"
fi