-
Notifications
You must be signed in to change notification settings - Fork 66
[chores] Add label guardrails in release process #2063
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
Merged
Drarig29
merged 8 commits into
master
from
corentin.girard/change-job-order-in-release-process
Jan 20, 2026
+86
−31
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9c69986
[chores] Change job order in release process
Drarig29 3ee5b2d
Add `--tolerate-republish` option
Drarig29 c5d45b4
Add comment about it
Drarig29 7e6a97d
Add label management
Drarig29 657cd90
Also check "Do Not Merge" label
Drarig29 c48cd89
Make it clear in script
Drarig29 b8a9142
Check if `PR_LABELS` is not empty
Drarig29 7d94b9f
Always "post echo" to avoid double new lines
Drarig29 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
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
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 |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ set -euo pipefail | |
|
|
||
| MODE="check" | ||
| DRY_RUN=false | ||
| GITHUB_REPOSITORY=DataDog/datadog-ci | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
|
|
@@ -63,7 +64,41 @@ while IFS= read -r pkg; do | |
| fi | ||
| done <<< "$local_packages" | ||
|
|
||
| # Exit early if everything is good | ||
| # Fetch PR information | ||
| PR_RESPONSE="" | ||
| PR_LABELS="" | ||
| if [ -n "${GITHUB_TOKEN:-}" ] && [ -n "${GITHUB_SHA:-}" ]; then | ||
| PR_RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||
| "https://api.github.com/repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls") | ||
| PR_LABELS=$(echo "$PR_RESPONSE" | jq '[.[0].labels[].name]' 2>/dev/null || true) | ||
|
|
||
| echo -e "${BLUE}PR labels:${NC} $PR_LABELS" | ||
| echo | ||
| fi | ||
|
|
||
| # In CI, check the labels on the PR | ||
| if [ -n "${GITHUB_TOKEN:-}" ] && [ -n "${GITHUB_SHA:-}" ]; then | ||
| # Fail if `Do Not Merge` is set | ||
| if echo "$PR_LABELS" | grep -q "Do Not Merge"; then | ||
| echo -e "${RED}This PR is marked as \"Do Not Merge\" ❌${NC}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Fail if the PR has `oidc-setup-required ⚠️` WITHOUT `oidc-setup-done ✅` | ||
| if echo "$PR_LABELS" | grep -q "oidc-setup-required ⚠️"; then | ||
| if ! echo "$PR_LABELS" | grep -q "oidc-setup-done ✅"; then | ||
| echo -e "${RED}This PR requires OIDC setup on some packages. Please ask an admin to follow the instructions at https://datadoghq.atlassian.net/wiki/x/QYDRaQE${NC}" | ||
| exit 1 | ||
| else | ||
| echo 'Continuing... No need to remove the `oidc-setup-required ⚠️` label.' | ||
| fi | ||
| else | ||
| echo 'Continuing... for the `oidc-setup-required ⚠️` label to possibly be added.' | ||
| fi | ||
| echo | ||
| fi | ||
|
|
||
| # Everything is good. | ||
| if [ ${#missing_packages[@]} -eq 0 ]; then | ||
| echo -e "${GREEN}All local packages exist on NPM ✅${NC}" | ||
| exit 0 | ||
|
|
@@ -76,11 +111,8 @@ for pkg in "${missing_packages[@]}"; do | |
| done | ||
|
|
||
| # In CI environment, post a comment on the PR | ||
| if [ -n "${GITHUB_TOKEN:-}" ] && [ -n "${GITHUB_REPOSITORY:-}" ] && [ -n "${GITHUB_SHA:-}" ]; then | ||
| # Get the PR number and author associated with this commit | ||
| PR_RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||
| "https://api.github.com/repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls") | ||
|
|
||
| if [ -n "${GITHUB_TOKEN:-}" ] && [ -n "${GITHUB_SHA:-}" ]; then | ||
| # PR_RESPONSE was already fetched above | ||
| PR_NUMBER=$(echo "$PR_RESPONSE" | jq -r '.[0].number // empty') | ||
| PR_AUTHOR=$(echo "$PR_RESPONSE" | jq -r '.[0].user.login // empty') | ||
|
|
||
|
|
@@ -99,11 +131,18 @@ Hi @$PR_AUTHOR, please **ask an admin** to follow the instructions at https://da | |
| # Post comment on the PR | ||
| curl -s -X POST \ | ||
| -H "Authorization: token $GITHUB_TOKEN" \ | ||
| -H "Accept: application/vnd.github.v3+json" \ | ||
| "https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ | ||
| -d "$(jq -n --arg body "$COMMENT_BODY" '{body: $body}')" > /dev/null | ||
|
|
||
| echo -e "${BLUE}Posted comment on PR #$PR_NUMBER (author: @$PR_AUTHOR)${NC}" | ||
|
|
||
| # Add the 'oidc-setup-required ⚠️' label to the PR | ||
| curl -s -X POST \ | ||
| -H "Authorization: token $GITHUB_TOKEN" \ | ||
| "https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/labels" \ | ||
| -d '{"labels":["oidc-setup-required ⚠️"]}' > /dev/null | ||
|
|
||
| echo -e "${BLUE}Added 'oidc-setup-required ⚠️' label to PR #$PR_NUMBER${NC}" | ||
| else | ||
| # Fallback when PR is not found | ||
| echo -e "${RED}No PR found for commit $GITHUB_SHA${NC}" | ||
|
|
@@ -181,3 +220,13 @@ if [ "$DRY_RUN" = true ]; then | |
| else | ||
| echo -e "${GREEN}Successfully published ${#missing_packages[@]} package(s)${NC}" | ||
| fi | ||
|
|
||
| echo | ||
| echo -e "${RED}${BOLD}⚠️ You are not done!${NC} Please setup OIDC on each package at the links below." | ||
| echo | ||
|
|
||
| for pkg in "${missing_packages[@]}"; do | ||
| echo -e " - Opening ${BLUE}https://www.npmjs.com/package/$pkg/access${NC}" | ||
| open "https://www.npmjs.com/package/$pkg/access" | ||
| done | ||
| echo | ||
|
Comment on lines
+223
to
+232
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
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.

Uh oh!
There was an error while loading. Please reload this page.