Skip to content

Commit 019114f

Browse files
authored
Merge pull request #4279 from amvanbaren/namespace-claim-issue-is-open
Namespace claim: Check issue is open before making changes
2 parents aabac88 + 8086e6a commit 019114f

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/workflows/claim-namespace.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,18 @@ jobs:
4646
with:
4747
endpoint: https://open-vsx.org/api/${{steps.get_namespace.outputs.namespace}}
4848
configuration: '{ "method": "GET" }'
49-
- id: namespace_not_found
49+
- id: namespace_not_found_should_close
5050
if: ${{ failure() && steps.get_namespace.outputs.namespace != null }}
51+
name: Check issue is still open before editing issue
52+
uses: octokit/[email protected]
53+
with:
54+
route: GET /repos/{repo}/issues/{issue_number}
55+
repo: ${{ github.repository }}
56+
issue_number: ${{ github.event.issue.number }}
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
- id: namespace_not_found
60+
if: ${{ failure() && fromJSON(steps.namespace_not_found_should_close.outputs.data).state == 'open' }}
5161
run: |
5262
gh issue edit "$NUMBER" --add-assignee "$ASSIGNEE"
5363
gh issue close "$NUMBER" -c "The namespace '$NAMESPACE' doesn't exist. Please publish your extension first and then open a new namespace claim issue." -r "not planned"
@@ -81,9 +91,19 @@ jobs:
8191
const members = JSON.parse(process.env.MEMBERS);
8292
const makeOwner = members.length == 1 && members[0].user.loginName == process.env.LOGIN_NAME && members[0].role == 'contributor';
8393
core.setOutput('makeOwner', makeOwner);
94+
- id: should_change_member
95+
if: ${{ steps.make_owner.outputs.makeOwner == 'true' }}
96+
name: Check issue is still open before changing namespace membership
97+
uses: octokit/[email protected]
98+
with:
99+
route: GET /repos/{repo}/issues/{issue_number}
100+
repo: ${{ github.repository }}
101+
issue_number: ${{ github.event.issue.number }}
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84104
- id: change_member
85105
name: Namespace change member API request
86-
if: ${{ steps.make_owner.outputs.makeOwner == 'true' }}
106+
if: ${{ steps.make_owner.outputs.makeOwner == 'true' && fromJSON(steps.should_change_member.outputs.data).state == 'open' }}
87107
uses: JamesIves/fetch-api-data-action@v2
88108
with:
89109
endpoint: https://open-vsx.org/admin/api/namespace/${{steps.get_namespace.outputs.namespace}}/change-member?user=${{github.event.issue.user.login}}&provider=github&role=owner&token=${{secrets.OPENVSX_TOKEN}}

0 commit comments

Comments
 (0)