Skip to content

Commit 0b723b3

Browse files
CopilotakoeplingerCopilot
authored
Add unlock functionality for reopened issues and PRs in locker workflow (#119003)
This PR enhances the `.github/workflows/locker.yml` workflow to automatically unlock issues and pull requests when they are reopened, addressing the need to make previously locked items accessible again when discussion resumes. ## Changes Made ### New Event Triggers - Added `issues.reopened` trigger to detect when closed issues are reopened - Added `pull_request_target.reopened` trigger to detect when closed PRs are reopened ### Enhanced Job Logic - **Lock job** (renamed from `main` for clarity): - Added condition to prevent execution on reopened events: `github.event_name != 'issues' && github.event_name != 'pull_request_target'` - Preserves existing functionality for scheduled runs and manual dispatch - **New unlock job**: - Only executes when issues or PRs are reopened: `github.event.action == 'reopened'` - Uses `actions/github-script@v7` with GitHub REST API to unlock items - Handles both issues and pull requests with a single step (since GitHub treats PRs as issues in the API) - Only unlocks if the item is actually locked: `github.event.issue.locked == true` ### Workflow Behavior - **Before**: Issues/PRs remained locked after being reopened, preventing further discussion - **After**: Issues/PRs are automatically unlocked when reopened, allowing immediate participation ## Technical Implementation The unlock functionality uses the GitHub Issues API (which also handles PRs) through `actions/github-script@v7`: ```javascript await github.rest.issues.unlock({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, }); ``` This ensures that when maintainers or contributors reopen issues or PRs for continued discussion, they won't encounter locked conversation threads that prevent community engagement. Fixes the workflow gap where reopened items remained inaccessible for comments despite being active again. <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/dotnet/runtime/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: akoeplinger <[email protected]> Co-authored-by: Alexander Köplinger <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 67e6e17 commit 0b723b3

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

.github/workflows/locker.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Locker - Lock stale issues and PRs
1+
name: Locker - Lock stale issues and PRs, unlock reopened ones
22
on:
33
schedule:
44
- cron: '37 8 * * *' # Once per day, early morning PT
@@ -13,14 +13,21 @@ on:
1313
required: true
1414
default: "30"
1515

16+
issues:
17+
types: [reopened]
18+
19+
pull_request_target:
20+
types: [reopened]
21+
1622
permissions:
1723
issues: write
1824
pull-requests: write
1925

2026
jobs:
21-
main:
27+
lock:
2228
runs-on: ubuntu-latest
23-
if: ${{ github.repository_owner == 'dotnet' }}
29+
# Only run the locking job for scheduled runs and manual dispatch, not for reopened events
30+
if: ${{ github.repository_owner == 'dotnet' && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }}
2431
steps:
2532
- name: Checkout Actions
2633
uses: actions/checkout@v6
@@ -35,3 +42,20 @@ jobs:
3542
with:
3643
daysSinceClose: ${{ fromJson(inputs.daysSinceClose || 30) }}
3744
daysSinceUpdate: ${{ fromJson(inputs.daysSinceUpdate || 30) }}
45+
46+
unlock:
47+
runs-on: ubuntu-latest
48+
# Only run the unlocking job when issues or PRs are reopened
49+
if: ${{ github.repository_owner == 'dotnet' && (github.event_name == 'issues' || github.event_name == 'pull_request_target') && github.event.action == 'reopened' }}
50+
steps:
51+
- name: Unlock if issue/PR is locked
52+
uses: actions/github-script@v7
53+
if: ${{ github.event.issue.locked == true }}
54+
with:
55+
script: |
56+
console.log(`Unlocking locked issue/PR #${context.issue.number}.`);
57+
await github.rest.issues.unlock({
58+
issue_number: context.issue.number,
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
});

0 commit comments

Comments
 (0)