aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/preview.yml
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-07 19:20:12 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-07 19:20:37 +0300
commit9c101b71d83941ee59d2b68f32f624afd7e2d78e (patch)
tree99953c9c681ec6cc37ddfe87e0cdc86589f2163d /.github/workflows/preview.yml
parent0a3c9b97bce321795ee897b370dba10e74df7ac5 (diff)
ci: mark issues released on preview
Diffstat (limited to '.github/workflows/preview.yml')
-rw-r--r--.github/workflows/preview.yml100
1 files changed, 100 insertions, 0 deletions
diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml
index a259ba54..7af41cf5 100644
--- a/.github/workflows/preview.yml
+++ b/.github/workflows/preview.yml
@@ -252,6 +252,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
+ issues: write
steps:
- uses: actions/checkout@v6
with:
@@ -264,6 +265,17 @@ jobs:
with:
path: artifacts
+ - name: Record previous preview commit
+ id: previous-preview
+ shell: bash
+ run: |
+ set -euo pipefail
+ previous="$(python3 scripts/preview.py current-commit --manifest website/preview.json || true)"
+ if [ -z "$previous" ]; then
+ previous="$(git describe --tags --match 'v[0-9]*' --abbrev=0)"
+ fi
+ echo "commit=$previous" >> "$GITHUB_OUTPUT"
+
- name: Generate notes and checksums
shell: bash
run: |
@@ -324,6 +336,94 @@ jobs:
git diff --cached --quiet || git commit -m "docs: update preview manifest"
git push "https://x-access-token:${KANGAL_GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:master
+ - name: Mark preview-released issues
+ continue-on-error: true
+ shell: bash
+ env:
+ GH_TOKEN: ${{ secrets.KANGAL_GITHUB_TOKEN }}
+ PREVIEW_RELEASED_LABEL: preview-released
+ run: |
+ set -euo pipefail
+
+ echo "Using GitHub token for $(gh api user --jq .login)."
+
+ PREVIEW_COMMIT='${{ needs.preflight.outputs.commit }}'
+ PREVIEW_TAG='${{ needs.preflight.outputs.tag }}'
+ PREVIEW_BUILD_ID='${{ needs.preflight.outputs.build_id }}'
+ PREVIOUS_PREVIEW_COMMIT='${{ steps.previous-preview.outputs.commit }}'
+
+ echo "Scanning preview commits in $PREVIOUS_PREVIEW_COMMIT..$PREVIEW_COMMIT for refs #<issue> mentions."
+ mapfile -t ISSUES < <(
+ git log --format='%s%n%b' "$PREVIOUS_PREVIEW_COMMIT..$PREVIEW_COMMIT" \
+ | perl -ne 'print "$1\n" if /\brefs\s+#([0-9]+)\b/i' \
+ | sort -nu
+ )
+
+ if [ "${#ISSUES[@]}" -eq 0 ]; then
+ echo "No preview issue refs found."
+ exit 0
+ fi
+
+ if ! gh api "repos/${GITHUB_REPOSITORY}/labels/${PREVIEW_RELEASED_LABEL}" >/dev/null 2>&1; then
+ gh api -X POST "repos/${GITHUB_REPOSITORY}/labels" \
+ -f name="$PREVIEW_RELEASED_LABEL" \
+ -f color="1D76DB" \
+ -f description="Available on the preview channel, pending a stable release." \
+ >/dev/null \
+ || gh api "repos/${GITHUB_REPOSITORY}/labels/${PREVIEW_RELEASED_LABEL}" >/dev/null
+ fi
+
+ PREVIEW_URL="https://github.com/${GITHUB_REPOSITORY}/releases/tag/${PREVIEW_TAG}"
+ PREVIEW_COMMENT_MARKER="<!-- herdr:preview-released:${PREVIEW_TAG} -->"
+ PREVIEW_COMMENT="${PREVIEW_COMMENT_MARKER}"$'\n'"Released on the preview channel in [${PREVIEW_BUILD_ID}](${PREVIEW_URL}). This is available to preview users, but is not in a stable Herdr release yet."
+
+ issue_has_comment_marker() {
+ local issue="$1"
+ local marker="$2"
+ local comments
+ if ! comments="$(gh api --paginate "repos/${GITHUB_REPOSITORY}/issues/${issue}/comments?per_page=100" --jq '.[].body')"; then
+ echo "::warning::Could not read comments for issue #$issue."
+ return 2
+ fi
+ grep -F -- "$marker" >/dev/null <<<"$comments"
+ }
+
+ for issue in "${ISSUES[@]}"; do
+ echo "Checking #$issue"
+ if ! data="$(gh api "repos/${GITHUB_REPOSITORY}/issues/${issue}")"; then
+ echo "::warning::Could not read issue #$issue; skipping."
+ continue
+ fi
+
+ if jq -e 'has("pull_request")' <<<"$data" >/dev/null; then
+ echo "Skipping #$issue because it is a pull request."
+ continue
+ fi
+
+ HAS_PREVIEW_LABEL="$(jq -r --arg label "$PREVIEW_RELEASED_LABEL" 'any(.labels[].name; . == $label)' <<<"$data")"
+ if [ "$HAS_PREVIEW_LABEL" != "true" ]; then
+ if ! gh issue edit "$issue" --repo "$GITHUB_REPOSITORY" --add-label "$PREVIEW_RELEASED_LABEL"; then
+ echo "::warning::Could not label issue #$issue."
+ continue
+ fi
+ fi
+
+ MARKER_STATUS=0
+ issue_has_comment_marker "$issue" "$PREVIEW_COMMENT_MARKER" || MARKER_STATUS="$?"
+ if [ "$MARKER_STATUS" -eq 2 ]; then
+ continue
+ fi
+ if [ "$MARKER_STATUS" -eq 0 ]; then
+ echo "Skipping preview release comment for #$issue because it already exists."
+ continue
+ fi
+
+ if ! gh issue comment "$issue" --repo "$GITHUB_REPOSITORY" --body "$PREVIEW_COMMENT"; then
+ echo "::warning::Could not comment on issue #$issue."
+ continue
+ fi
+ done
+
- name: Prune old preview prereleases
env:
GH_TOKEN: ${{ github.token }}