-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add milestones workflow for Merged PRs #23049
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
Open
NouemanKHAL
wants to merge
4
commits into
master
Choose a base branch
from
noueman/add-milestone-for-merged-prs-workflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+99
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6567f92
add release.json to track current_milestone
NouemanKHAL cebc642
add milestone workflow for merged PRs to master and release branches
NouemanKHAL 260ab53
move to dd-octo-sts
NouemanKHAL beeef7b
apply dd-octo-sts claude skill recommendations
NouemanKHAL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
.github/chainguard/self.add-milestone.pull-request.sts.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Trust policy for the add-milestone workflow in DataDog/integrations-core | ||
| # | ||
| # This policy grants the workflow permission to set a milestone on merged pull | ||
| # requests targeting master or release branches. | ||
| # | ||
| # Naming convention: | ||
| # self: Only this repository (DataDog/integrations-core) can use this policy | ||
| # add-milestone: Grants permissions to update pull request milestones | ||
| # pull-request: Intended for workflows triggered by pull_request events | ||
| # | ||
| # Security model: | ||
| # - Workflow runs on pull_request (closed) events targeting protected branches | ||
| # - ref restricts to master and protected X.Y.x release branches (protected by org rulesets) | ||
| # - job_workflow_ref is matched by pattern since PR events reference refs/pull/N/merge | ||
| # | ||
| # Permissions granted: | ||
| # - pull_requests: write - Set the milestone on the merged pull request | ||
| # | ||
| # Usage in workflows: | ||
| # - uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3 | ||
| # with: | ||
| # scope: DataDog/integrations-core | ||
| # policy: self.add-milestone.pull-request | ||
|
|
||
| issuer: https://token.actions.githubusercontent.com | ||
|
|
||
| subject: repo:DataDog/integrations-core:pull_request | ||
|
|
||
| claim_pattern: | ||
| event_name: pull_request | ||
| job_workflow_ref: DataDog/integrations-core/\.github/workflows/add-milestone\.yml@.* | ||
| ref: refs/heads/(master|\d+\.\d+\.x) | ||
| repository: DataDog/integrations-core | ||
|
|
||
| permissions: | ||
| pull_requests: write |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| name: Add Milestone on a Merged PR | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: | ||
| - closed | ||
| branches: | ||
| - master | ||
| - "[0-9]+.[0-9]+.x" | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| add-milestone-pr: | ||
| name: Add Milestone on PR | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write # Required for OIDC token federation with dd-octo-sts | ||
| contents: read | ||
| env: | ||
| GH_REPO: ${{ github.repository }} | ||
| steps: | ||
| - name: Checkout integrations-core repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Get GitHub token via dd-octo-sts | ||
| uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3 | ||
| id: octo-sts | ||
| with: | ||
| scope: DataDog/integrations-core | ||
| policy: self.add-milestone.pull-request | ||
|
|
||
| - name: Get repo current milestone | ||
| id: current-milestone | ||
| run: | | ||
| # Use the current_milestone field in the release.json file. | ||
| MILESTONE=$(cat release.json | jq -r .current_milestone) | ||
| if [ -z "$MILESTONE" ]; then | ||
| echo "Error: Couldn't find the current_milestone field in the release.json file." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! $MILESTONE =~ ^7\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Error: Malformed milestone $MILESTONE. It should be of the form '7.x.y'." | ||
| exit 1 | ||
| fi | ||
| echo "MILESTONE=$MILESTONE" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Set the merged PR milestone to current_milestone from release.json | ||
| run: | | ||
| echo "Setting milestone $MILESTONE to PR $NUMBER." | ||
| gh issue edit "$NUMBER" --milestone "$MILESTONE" | ||
| env: | ||
| GH_TOKEN: ${{ steps.octo-sts.outputs.token }} | ||
| NUMBER: ${{ github.event.number }} | ||
| MILESTONE: ${{ steps.current-milestone.outputs.MILESTONE }} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "current_milestone": "7.79.0" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow is wired to
pull_requestevents, but it performs a write operation withgh issue editlater in the job; for PRs coming from forks (including Dependabot),GITHUB_TOKENis read-only onpull_request, so merged external PRs will fail to set milestones. In practice this means a non-trivial share of merged PRs will never be milestoned even though the workflow runs.Useful? React with 👍 / 👎.