mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-08-16 04:39:15 +00:00
ci: support manual standalone build trigger and PR comment (#1091)
* ci: add manually trigger build Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: PR comment Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
be6e9b5f06
commit
3a2c6e3a3d
45
.github/workflows/build-standalone-on-merge.yaml
vendored
45
.github/workflows/build-standalone-on-merge.yaml
vendored
@ -1,6 +1,7 @@
|
|||||||
name: Build Standalone on PR Merge
|
name: Build Standalone on PR Merge
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
@ -29,3 +30,47 @@ jobs:
|
|||||||
id-token: write
|
id-token: write
|
||||||
with:
|
with:
|
||||||
CI_BRANCH: ${{github.ref_name}}
|
CI_BRANCH: ${{github.ref_name}}
|
||||||
|
comment-on-pr:
|
||||||
|
name: Comment build result on PR
|
||||||
|
# Only for manual runs so the existing push / pull_request flows are untouched.
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
steps:
|
||||||
|
- name: Add build artifact comment to the PR opened from this branch
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const branch = context.ref.replace('refs/heads/', '');
|
||||||
|
const { data: prs } = await github.rest.pulls.list({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
state: 'open',
|
||||||
|
head: `${context.repo.owner}:${branch}`,
|
||||||
|
base: 'main',
|
||||||
|
});
|
||||||
|
if (prs.length === 0) {
|
||||||
|
core.info(`No open PR found for branch ${branch}, skipping comment.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Match scripts/version: sanitize the branch and map main -> latest.
|
||||||
|
const dir = branch === 'main'
|
||||||
|
? 'latest'
|
||||||
|
: branch.replace(/[^a-zA-Z0-9.-]+/g, '-');
|
||||||
|
const url = `https://releases.rancher.com/harvester-ui/dashboard/${dir}/index.html`;
|
||||||
|
const 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,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user