ci: not use actions/github-script@v7 (#1092)

Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
Andy Lee 2026-08-05 14:37:24 +08:00 committed by GitHub
parent 3a2c6e3a3d
commit 823a88c85b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
name: Build Standalone on PR Merge name: Build Standalone on PR Merge
on: on:
workflow_dispatch: workflow_dispatch: # manually trigger on Github Actions only support PR branch pushed to harvester/harvester-ui-extension
push: push:
branches: branches:
- main - main
@ -41,36 +41,24 @@ jobs:
pull-requests: write pull-requests: write
steps: steps:
- name: Add build artifact comment to the PR opened from this branch - name: Add build artifact comment to the PR opened from this branch
uses: actions/github-script@v7 env:
with: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
script: | BRANCH: ${{ github.ref_name }}
const branch = context.ref.replace('refs/heads/', ''); run: |
const { data: prs } = await github.rest.pulls.list({ set -euo pipefail
owner: context.repo.owner, # Match scripts/version: sanitize the branch and map main -> latest.
repo: context.repo.repo, if [ "$BRANCH" = "main" ]; then
state: 'open', DIR="latest"
head: `${context.repo.owner}:${branch}`, else
base: 'main', DIR=$(printf '%s' "$BRANCH" | sed -E 's/[^a-zA-Z0-9.-]+/-/g')
}); fi
if (prs.length === 0) { URL="https://releases.rancher.com/harvester-ui/dashboard/${DIR}/index.html"
core.info(`No open PR found for branch ${branch}, skipping comment.`);
return; PR=$(gh pr list --repo "$GITHUB_REPOSITORY" --state open --base main --head "$BRANCH" --json number --jq '.[0].number // empty')
} if [ -z "$PR" ]; then
// Match scripts/version: sanitize the branch and map main -> latest. echo "No open PR found for branch $BRANCH, skipping comment."
const dir = branch === 'main' exit 0
? 'latest' fi
: branch.replace(/[^a-zA-Z0-9.-]+/g, '-');
const url = `https://releases.rancher.com/harvester-ui/dashboard/${dir}/index.html`; BODY=$(printf '🚀 **UI Artifact Build Status:** `SUCCESS` ✅\n> ui-index: %s\n> ui-source: external' "$URL")
const body = [ gh pr comment "$PR" --repo "$GITHUB_REPOSITORY" --body "$BODY"
'🚀 **UI Artifact Build Status:** `SUCCESS` ✅',
`> ui-index: ${url}`,
`> ui-source: external`
].join('\n');
for (const pr of prs) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body,
});
}