mirror of
https://github.com/openai/codex-security.git
synced 2026-11-23 09:59:21 +08:00
* fix(build): preserve artifacts and align CI and release checks * Preserve platform compatibility and prevent stale container promotion retries * test(build): compile stdin import helpers in a temporary fixture * test: distinguish Markdown workflow fixture identities * fix(ci): restore changed Markdown formatting checks * test(ci): follow renamed Markdown formatting step * fix(build): allow maintainer imports from virtual entrypoints * fix(build): resolve both standalone entrypoint paths * Keep maintainer eval imports inert with matching positional paths * fix(build): keep combined evaluation imports inactive * test(build): preserve portable preload paths across runtimes * Preserve manual release categories after pull request retitling * fix: reconcile automatic labels after manual release overrides * test: batch workflow condition evaluations * Disambiguate manual release category test identities * Use asynchronous Bash workflow fixture and preserve process diagnostics * Pass workflow condition scripts through existing stdin helper --------- Co-authored-by: Codex <codex@users.noreply.github.com>
188 lines
6.3 KiB
YAML
188 lines
6.3 KiB
YAML
name: node-release-labels
|
|
|
|
on:
|
|
pull_request_target:
|
|
branches: [main]
|
|
types: [opened, edited, reopened]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: node-release-labels-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
categorize:
|
|
if: github.repository == 'openai/codex-security'
|
|
name: categorize release notes
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Categorize pull request without checking out its code
|
|
shell: bash
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
release_note_label() {
|
|
local type="$1" breaking_marker="$2" scope="$3"
|
|
if [[ "$breaking_marker" == "!" ]]; then
|
|
printf '%s\n' breaking-change
|
|
return 0
|
|
fi
|
|
|
|
case "$type" in
|
|
feat)
|
|
printf '%s\n' enhancement
|
|
;;
|
|
fix)
|
|
printf '%s\n' bug
|
|
;;
|
|
docs)
|
|
printf '%s\n' documentation
|
|
;;
|
|
release | test)
|
|
printf '%s\n' skip-release-notes
|
|
;;
|
|
chore)
|
|
if [[ "$scope" == "(release)" ]]; then
|
|
printf '%s\n' skip-release-notes
|
|
fi
|
|
;;
|
|
*)
|
|
return 0
|
|
;;
|
|
esac
|
|
}
|
|
|
|
title_sentinel="__CODEX_SECURITY_TITLE_END__"
|
|
current_title="$(
|
|
gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER" \
|
|
--jq '.title | @base64' |
|
|
node --input-type=module --eval '
|
|
import { readFileSync } from "node:fs";
|
|
process.stdout.write(
|
|
Buffer.from(readFileSync(0, "utf8"), "base64"),
|
|
);
|
|
' &&
|
|
printf '%s' "$title_sentinel"
|
|
)"
|
|
current_title="${current_title%"$title_sentinel"}"
|
|
conventional_title='^([a-z][a-z0-9-]*)(\([a-z0-9][a-z0-9._/-]*\))?(!)?:[ ]([^[:space:]].*[^[:space:]]|[^[:space:]])$'
|
|
if [[ "$current_title" == *$'\n'* ||
|
|
"$current_title" == *$'\r'* ||
|
|
! "$current_title" =~ $conventional_title ]]; then
|
|
echo "Pull request title must follow <type>[optional scope][!]: <description>." >&2
|
|
exit 1
|
|
fi
|
|
type="${BASH_REMATCH[1]}"
|
|
scope="${BASH_REMATCH[2]:-}"
|
|
breaking_marker="${BASH_REMATCH[3]:-}"
|
|
label="$(release_note_label "$type" "$breaking_marker" "$scope")"
|
|
current_labels="$(
|
|
gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/labels" \
|
|
--jq '.[].name'
|
|
)"
|
|
|
|
label_events=""
|
|
if [[ -n "$current_labels" ]]; then
|
|
label_events="$(
|
|
gh api \
|
|
"repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/timeline?per_page=100" \
|
|
--paginate \
|
|
--jq '.[] | select(.event == "labeled") | [.label.name, (.actor.login // "__unattributed__")] | @tsv'
|
|
)"
|
|
fi
|
|
|
|
label_already_present=false
|
|
manual_category_present=false
|
|
bot_labels=""
|
|
while IFS= read -r current_label; do
|
|
case "$current_label" in
|
|
breaking-change | enhancement | bug | documentation | skip-release-notes)
|
|
label_actor=""
|
|
while IFS=$'\t' read -r event_label event_actor; do
|
|
if [[ "$event_label" == "$current_label" ]]; then
|
|
label_actor="$event_actor"
|
|
fi
|
|
done <<< "$label_events"
|
|
if [[ "$label_actor" != "github-actions[bot]" ]]; then
|
|
echo "Preserving existing $current_label label."
|
|
if [[ "$current_label" != "skip-release-notes" || "$current_label" == "$label" ]]; then
|
|
label_already_present=true
|
|
fi
|
|
if [[ "$current_label" != "skip-release-notes" ]]; then
|
|
manual_category_present=true
|
|
fi
|
|
else
|
|
bot_labels+="$current_label"$'\n'
|
|
fi
|
|
;;
|
|
esac
|
|
done <<< "$current_labels"
|
|
|
|
while IFS= read -r current_label; do
|
|
if [[ -z "$current_label" ]]; then
|
|
continue
|
|
fi
|
|
if [[ "$manual_category_present" == true || "$current_label" != "$label" ]]; then
|
|
gh api --method DELETE \
|
|
"repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/labels/$current_label" \
|
|
--silent
|
|
else
|
|
label_already_present=true
|
|
fi
|
|
done <<< "$bot_labels"
|
|
|
|
if [[ -z "$label" ]]; then
|
|
echo "No automatic release-note category applies."
|
|
exit 0
|
|
fi
|
|
|
|
if [[ "$label_already_present" == true ]]; then
|
|
echo "The current release-note category is already applied."
|
|
exit 0
|
|
fi
|
|
|
|
ensure_repository_label() {
|
|
local name="$1" color="$2" description="$3"
|
|
if ! gh api \
|
|
"repos/$GITHUB_REPOSITORY/labels/$name" \
|
|
--silent >/dev/null 2>&1; then
|
|
if ! gh api --method POST "repos/$GITHUB_REPOSITORY/labels" \
|
|
-f "name=$name" \
|
|
-f "color=$color" \
|
|
-f "description=$description" \
|
|
--silent >/dev/null 2>&1; then
|
|
gh api \
|
|
"repos/$GITHUB_REPOSITORY/labels/$name" \
|
|
--silent >/dev/null
|
|
fi
|
|
fi
|
|
}
|
|
|
|
case "$label" in
|
|
breaking-change)
|
|
ensure_repository_label \
|
|
breaking-change b60205 \
|
|
"Breaking change called out in generated release notes"
|
|
;;
|
|
skip-release-notes)
|
|
ensure_repository_label \
|
|
skip-release-notes ededed \
|
|
"Omit internal changes from generated release notes"
|
|
;;
|
|
esac
|
|
|
|
gh api --method POST \
|
|
"repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/labels" \
|
|
-f "labels[]=$label" \
|
|
--silent
|