Skip to content

Commit ecc75a2

Browse files
author
amvanbaren
committed
Automate namespace claim process
1 parent 2ff849a commit ecc75a2

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

.github/workflows/claim-namespace.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,31 @@ jobs:
2929
name: Log namespace name
3030
run: echo "${{steps.get_namespace.outputs.namespace}}"
3131
- id: get_namespace_data
32-
name: Namespace API request
32+
name: Namespace members API request
3333
uses: JamesIves/fetch-api-data-action@v2
3434
with:
35-
endpoint: https://open-vsx.org/api/${{steps.get_namespace.outputs.namespace}}
35+
endpoint: https://open-vsx.org/admin/api/namespace/${{steps.get_namespace.outputs.namespace}}/members?token=${{secrets.OPENVSX_TOKEN}}
3636
configuration: '{ "method": "GET" }'
37-
- id: namespace_dispute
38-
name: Namespace dispute
39-
if: ${{ fromJSON(steps.get_namespace_data.outputs.fetchApiData).verified == true && !contains(github.event.issue.labels.*.name, 'dispute') }}
40-
run: gh issue edit "$NUMBER" --add-label "$LABELS"
41-
env:
42-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43-
GH_REPO: ${{ github.repository }}
44-
NUMBER: ${{ github.event.issue.number }}
45-
LABELS: dispute
46-
- id: no_namespace_dispute
47-
name: Namespace not disputed
48-
if: ${{ fromJSON(steps.get_namespace_data.outputs.fetchApiData).verified == false && contains(github.event.issue.labels.*.name, 'dispute') }}
49-
run: gh issue edit "$NUMBER" --remove-label "$LABELS"
37+
- id: namespace_members
38+
run: echo "members=${{ fromJSON(steps.get_namespace_data.outputs.fetchApiData).namespaceMemberships }}" >> "$GITHUB_OUTPUT"
39+
- id: make_owner
40+
run: echo "makeOwner=${{ steps.namespace_members.outputs.members.length == 1 && steps.namespace_members.outputs.members[0].user.loginName == github.event.issue.user.login && steps.namespace_members.outputs.members[0].role == 'contributor' }}" >> "$GITHUB_OUTPUT"
41+
- id: change_member
42+
name: Namespace change member API request
43+
if: ${{ steps.make_owner.outputs.makeOwner }}
44+
uses: JamesIves/fetch-api-data-action@v2
45+
with:
46+
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}}
47+
configuration: '{ "method": "POST" }'
48+
- id: grant_namespace
49+
name: Grant namespace
50+
if: ${{ fromJSON(steps.change_member.outputs.fetchApiData).success == format('Changed role of {0} in {1} to owner.', github.event.issue.user.login, steps.get_namespace.outputs.namespace) }}
51+
run: |
52+
gh issue edit "$NUMBER" --add-label "$LABELS" --add-assignee "$ASSIGNEE"
53+
gh issue close "$NUMBER" -r "completed"
5054
env:
5155
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5256
GH_REPO: ${{ github.repository }}
5357
NUMBER: ${{ github.event.issue.number }}
54-
LABELS: dispute
58+
LABELS: granted
59+
ASSIGNEE: amvanbaren

0 commit comments

Comments
 (0)