Skip to content

Commit 109bde6

Browse files
use actions/github-script for cleanup label adding (apollographql#12310)
Co-authored-by: Jerel Miller <[email protected]>
1 parent 86f23a4 commit 109bde6

File tree

4 files changed

+210
-4
lines changed

4 files changed

+210
-4
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @ts-check
2+
/** @param {import('@actions/github-script').AsyncFunctionArguments} AsyncFunctionArguments */
3+
export function setup({ context, github }) {
4+
return {
5+
async add_cleanup_label() {
6+
await github.rest.issues.addLabels({
7+
owner: context.repo.owner,
8+
repo: context.repo.repo,
9+
issue_number: context.issue.number,
10+
labels: ["auto-cleanup"],
11+
});
12+
},
13+
};
14+
}

.github/workflows/cleanup-checks.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@ jobs:
1111
if: |
1212
github.repository == 'apollographql/apollo-client' &&
1313
github.event.review.state == 'APPROVED' &&
14+
github.event.review.author_association == 'MEMBER' &&
1415
contains(github.event.pull_request.labels.*.name, 'auto-cleanup') == false
1516
runs-on: ubuntu-latest
16-
permissions:
17-
issues: write
1817
steps:
1918
- name: Checkout repo
2019
uses: actions/checkout@v4
2120
- name: add label
22-
uses: actions-ecosystem/action-add-labels@v1
21+
uses: actions/[email protected]
2322
with:
24-
labels: auto-cleanup
23+
script: |
24+
const script = (await import('${{ github.workspace }}/.github/workflows/cleanup-checks.mjs')).setup({context,core,github,exec,glob,io})
25+
await script.add_cleanup_label()
2526
2627
cleanup:
2728
if: |

package-lock.json

Lines changed: 190 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"zen-observable-ts": "^1.2.5"
109109
},
110110
"devDependencies": {
111+
"@actions/github-script": "github:actions/github-script#v7.0.1",
111112
"@arethetypeswrong/cli": "0.15.3",
112113
"@ark/attest": "0.28.0",
113114
"@babel/parser": "7.25.0",

0 commit comments

Comments
 (0)