mirror of
https://github.com/pockethost/pockethost.git
synced 2025-11-24 06:25:48 +00:00
chore(root): Add dashboard preview links to PRs
This commit is contained in:
parent
d5e850041e
commit
2e4ae1f417
35
.github/workflows/publish-dashboard.yaml
vendored
35
.github/workflows/publish-dashboard.yaml
vendored
@ -7,6 +7,13 @@ on:
|
||||
- packages/dashboard/**
|
||||
- package.json
|
||||
- pnpm-lock.yaml
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
paths:
|
||||
- .github/workflows/publish-dashboard.yaml
|
||||
- packages/dashboard/**
|
||||
- package.json
|
||||
- pnpm-lock.yaml
|
||||
|
||||
env:
|
||||
PUBLIC_APEX_DOMAIN: ${{ vars.PUBLIC_APEX_DOMAIN }}
|
||||
@ -18,6 +25,7 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
deployments: write
|
||||
pull-requests: write
|
||||
name: Publish to Cloudflare Pages
|
||||
steps:
|
||||
- name: Checkout
|
||||
@ -52,6 +60,33 @@ jobs:
|
||||
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
command: pages deploy ./packages/dashboard/build --project-name=pockethost --branch=${{ github.head_ref || github.ref_name }}
|
||||
|
||||
- name: Find related pull request
|
||||
id: find_pr
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
const { owner, repo } = context.repo
|
||||
const branch = (context.payload.pull_request && context.payload.pull_request.head && context.payload.pull_request.head.ref)
|
||||
|| process.env.GITHUB_HEAD_REF
|
||||
|| process.env.GITHUB_REF_NAME
|
||||
const prs = await github.rest.pulls.list({ owner, repo, state: 'open', head: `${owner}:${branch}` })
|
||||
if (prs.data.length > 0) {
|
||||
return String(prs.data[0].number)
|
||||
}
|
||||
return ''
|
||||
|
||||
- name: Comment preview URL on PR
|
||||
if: steps.find_pr.outputs.result != ''
|
||||
uses: marocchino/sticky-pull-request-comment@v2
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
number: ${{ steps.find_pr.outputs.result }}
|
||||
header: pockethost-dashboard-preview
|
||||
message: |
|
||||
✅ Preview available: ${{ steps.deployment.outputs.deployment-url }}
|
||||
Triggered by @${{ github.actor }} on `${{ github.ref_name }}`.
|
||||
|
||||
- name: Discord feature branch notification
|
||||
if: github.ref_name != env.MAIN_BRANCH
|
||||
env:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user