https://github.com/scientific-python/attach-next-milestone-action
Attach the next open milestone to a merged PR
https://github.com/scientific-python/attach-next-milestone-action
Last synced: 2 months ago
JSON representation
Attach the next open milestone to a merged PR
- Host: GitHub
- URL: https://github.com/scientific-python/attach-next-milestone-action
- Owner: scientific-python
- License: bsd-3-clause
- Created: 2023-05-27T17:31:40.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-07T05:52:09.000Z (about 1 year ago)
- Last Synced: 2026-01-21T08:54:29.247Z (2 months ago)
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 2
- Watchers: 5
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Attach Next Milestone Action
This action attaches the next open milestone to merged PRs.
Currently, this action only looks at milestones that can be parsed as
version numbers.
A typical job would look like this:
```yaml
# .github/workflows/milestone-merged-prs.yaml
name: Milestone
on:
pull_request_target:
types:
- closed
branches:
- 'main'
jobs:
milestone_pr:
name: attach to PR
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: scientific-python/attach-next-milestone-action@a4889cfde7d2578c1bc7400480d93910d2dd34f6
with:
token: ${{ secrets.MILESTONE_LABELER_TOKEN }}
```
To use the above, you will need to set a repository secret
`MILESTONE_LABELER_TOKEN` to a [fine-grained access token](https://github.blog/2022-10-18-introducing-fine-grained-personal-access-tokens-for-github/)
that has *read & write* permissions to modify *both* issues and PRs.
If you are generating a token for your org, you first need to enable fine-grained access tokens at
`https://github.com/organizations//settings/personal-access-tokens-onboarding`.
You can generate the token itself at https://github.com/settings/apps.
1. Personal access tokens -> Fine-grained tokens. Generate new token. Token name: milestone-labeler-token.
2. Select the org which owns the code repository.
If you don't see your organization listed, you first need to
[onboard it](https://github.com/organizations//settings/personal-access-tokens-onboarding).
3. Choose "Only Select Repositories", and choose the correct one.
4. Permissions:
- Repository Permissions -> Pull Requests -> Read and write.
- Repository Permissions -> Issues -> Read and write.
6. Generate the token. If an error appears saying "Sorry, something went wrong", ignore it.
Copy the token, and navigate to your code repository. Under Settings
-> Secrets and variables -> Actions, add a repository secret named
`MILESTONE_LABELER_TOKEN`, and set its contents to the generated
token.
## Options
In the `with` clause, the following options are available:
- `force: true` : Overwrite existing milestones.
## Warning!
The workflow above runs as `pull_request_target`, meaning it has access to repository secrets.
This is not usually a problem, since our action does nothing but attach a milestone to a PR using the provided token.
But, you should **not add further commands to the workflow**, such as checking out the PR and executing code from it.
If you do that, PR authors can gain access to your secrets.