mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-08-16 04:39:15 +00:00
65 lines
2.0 KiB
YAML
65 lines
2.0 KiB
YAML
name: Build Standalone on PR Merge
|
|
|
|
on:
|
|
workflow_dispatch: # manually trigger on Github Actions only support PR branch pushed to harvester/harvester-ui-extension
|
|
push:
|
|
branches:
|
|
- main
|
|
- 'release-harvester-v*'
|
|
- '*-dev'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- 'release-harvester-v*'
|
|
- '*-dev'
|
|
types:
|
|
- merged
|
|
|
|
jobs:
|
|
build-validation:
|
|
name: Build Test
|
|
uses: ./.github/workflows/run-lint.yaml
|
|
build:
|
|
name: Build and Upload Package
|
|
uses: ./.github/workflows/build-and-publish-standalone.yaml
|
|
needs:
|
|
- build-validation
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
id-token: write
|
|
with:
|
|
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
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
BRANCH: ${{ github.ref_name }}
|
|
run: |
|
|
set -euo pipefail
|
|
# Match scripts/version: sanitize the branch and map main -> latest.
|
|
if [ "$BRANCH" = "main" ]; then
|
|
DIR="latest"
|
|
else
|
|
DIR=$(printf '%s' "$BRANCH" | sed -E 's/[^a-zA-Z0-9.-]+/-/g')
|
|
fi
|
|
URL="https://releases.rancher.com/harvester-ui/dashboard/${DIR}/index.html"
|
|
|
|
PR=$(gh pr list --repo "$GITHUB_REPOSITORY" --state open --base main --head "$BRANCH" --json number --jq '.[0].number // empty')
|
|
if [ -z "$PR" ]; then
|
|
echo "No open PR found for branch $BRANCH, skipping comment."
|
|
exit 0
|
|
fi
|
|
|
|
BODY=$(printf '🚀 **UI Artifact Build Status:** `SUCCESS` ✅\n> ui-index: %s\n> ui-source: external' "$URL")
|
|
gh pr comment "$PR" --repo "$GITHUB_REPOSITORY" --body "$BODY"
|