Skip to content

Commit

Permalink
Migrate to actions/github-script Github Action (#101)
Browse files Browse the repository at this point in the history
The currently used `actions-ecosystem/action-remove-labels` and
`actions-ecosystem/action-add-labels` seem unmaintained and don't work
anymore because of using deprecated Nodejs 12 version.

Therefore, migrate a better maintained solution.

Signed-off-by: rustyclock <[email protected]>
  • Loading branch information
rustycl0ck authored Jun 30, 2023
1 parent 692c3c1 commit 8e8ee06
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ name: Size

on:
pull_request:
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
pull_request_target:
types: [opened, synchronize, reopened, edited, labeled, unlabeled]

jobs:
update_labels:
add_size_labels:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -16,10 +19,34 @@ jobs:
- uses: actions-ecosystem/action-size@v2
id: size

- uses: actions-ecosystem/action-remove-labels@v1
- name: remove old size labels
if: ${{ steps.size.outputs.stale_labels != '' }}
continue-on-error: true ## don't fail CI checks even if labelling fails for some reasons
uses: actions/github-script@v6
with:
labels: ${{ steps.size.outputs.stale_labels }}
script: |
const stale_labels = `${{ steps.size.outputs.stale_labels }}`;
const remove_labels = stale_labels.split('\n');
for (const label of remove_labels) {
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: label,
})
}
- uses: actions-ecosystem/action-add-labels@v1
## ref: https://github.com/actions/github-script#apply-a-label-to-an-issue
- name: apply new size label
if: ${{ steps.size.outputs.new_label != '' }}
continue-on-error: true ## don't fail CI checks even if labelling fails for some reasons
uses: actions/github-script@v6
with:
labels: ${{ steps.size.outputs.new_label }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['${{ steps.size.outputs.new_label }}'],
})

0 comments on commit 8e8ee06

Please sign in to comment.