Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade the branch-label action to use Node.js v20 #122

Conversation

eason9487
Copy link
Member

Changes proposed in this Pull Request:

Part of #108

This PR upgrades the branch-label action to use Node.js v20.

  • The actions-ecosystem/action-add-labels action has not been updated for almost 4 years. Therefore, this PR changes to use an alternative actions/labeler action to achieve the same function.
  • In addition, to avoid the issue of not having permission to add labels to pull requests, the example changes the recommended event to the pull_request_target instead of pull_request.

Detailed test instructions:

📌 Using Node.js v20

  1. View a previous workflow run used v1 action
  2. View test workflow runs used updated action

📌 View testing PRs to see if the alternative implementation can achieve the same results

1️⃣ Add a label: eason9487#24

image

2️⃣ Add multiple labels: eason9487#25

image

3️⃣ Mismatched branch name: eason9487#26

No labels are added because the branch name fixed/space-time-rift didn't match any rules.

image

4️⃣ No required permissions: eason9487#29

This test explains that a workflow uses pull_request event may result in permission issue when a PR is created from forks.

image
image

@eason9487 eason9487 requested a review from a team April 26, 2024 08:53
@eason9487 eason9487 self-assigned this Apr 26, 2024
@eason9487 eason9487 mentioned this pull request Apr 26, 2024
26 tasks
Copy link

@jorgemd24 jorgemd24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @eason9487 for working on this! I tested creating some PRs in a fork branch and it worked well, so LGTM 👍 I left some comments but they are not blockers.


#### Permissions:

It's recommended to use the `pull_request_target` event instead of `pull_request` to avoid the issue of not having permission to add labels to pull requests.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this action, we're not directly interacting with the code from the PR, so we're OK. However, shouldn't we also mention here that pull_request_target will grant access to secrets for PRs from forks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Added in 424eada.


Ref:
- https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
- https://github.com/actions/labeler/tree/v5#permissions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are using the labeler action, I think this link can be useful too: https://github.com/actions/labeler?tab=readme-ov-file#usage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 424eada.

…o the `branch-label` action in the `github-actions` package.

Address:
- #122 (comment)
- #122 (comment)
@eason9487 eason9487 merged commit a51305f into update/108-nodejs-v20 May 9, 2024
2 checks passed
@eason9487 eason9487 deleted the update/108-nodejs-v20-github-actions-branch-label branch May 9, 2024 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants