Skip to content

Commit 0731bc2

Browse files
[actions] fix weekly action to "work" (#1214)
This pull request updates the `.github/workflows/weekly-stable-updates.yml` file to enhance the workflow for creating weekly stable updates issues. The changes improve issue management by preventing duplicate issues, adding permissions, and assigning issues to the appropriate assignee. ### Workflow Enhancements: * Added `permissions` block to allow writing to issues. * Updated the `schedule` trigger formatting for clarity. ### Issue Management Improvements: * Introduced a check to prevent duplicate issues by searching for existing issues with the same title before creating a new one. * Added a step to assign the newly created issue to the `@copilot` user using the `gh` CLI. * Added `id: create-issue` to the "Create weekly stable updates issue" job for referencing outputs in subsequent steps.
1 parent 6751878 commit 0731bc2

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

.github/workflows/weekly-stable-updates.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: "Weekly Stable Updates"
22

3+
permissions:
4+
issues: write
5+
36
on:
4-
#schedule:
7+
schedule:
58
# Run every Monday at 9:00 AM UTC
6-
# - cron: '0 9 * * 1'
9+
- cron: '0 9 * * 1'
710
workflow_dispatch: # Allow manual triggering for testing
811

912
jobs:
@@ -16,6 +19,7 @@ jobs:
1619
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
1720

1821
- name: Create weekly stable updates issue
22+
id: create-issue
1923
uses: actions/github-script@v7
2024
with:
2125
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -39,12 +43,31 @@ jobs:
3943
4044
And put the contents from this command in the PR description and commit messages.`;
4145
46+
// Check for existing issues with the same title
47+
const existingIssues = await github.rest.issues.listForRepo({
48+
owner: context.repo.owner,
49+
repo: context.repo.repo,
50+
state: 'open',
51+
per_page: 100
52+
});
53+
const duplicateIssue = existingIssues.data.find(issue => /^Stable Updates \d{8}$/.test(issue.title));
54+
if (duplicateIssue) {
55+
console.log(`Issue with title "${duplicateIssue.title}" already exists: #${duplicateIssue.number}`);
56+
return;
57+
}
58+
4259
const response = await github.rest.issues.create({
4360
owner: context.repo.owner,
4461
repo: context.repo.repo,
4562
title: title,
4663
body: body,
47-
assignees: ['copilot-swe-agent']
4864
});
4965
5066
console.log(`Created issue #${response.data.number}: ${response.data.title}`);
67+
core.setOutput('issue-number', response.data.number);
68+
69+
- name: Add assignee to issue
70+
if: steps.create-issue.outputs.issue-number && steps.create-issue.outputs.issue-number != ''
71+
run: gh issue edit ${{ steps.create-issue.outputs.issue-number }} --add-assignee "@copilot" -R dotnet/android-libraries
72+
env:
73+
GH_TOKEN: ${{ secrets.ANDROID_TEAM_PAT }}

0 commit comments

Comments
 (0)