|
|
name: Publish Design System Docs PR Preview |
|
|
|
|
|
on: |
|
|
pull_request: |
|
|
types: [opened, synchronize, reopened] |
|
|
paths: |
|
|
- apps/design-system-docs/** |
|
|
- .github/actions/build-design-system-docs/action.yml |
|
|
- .github/workflows/ds-docs-pr-preview.yml |
|
|
|
|
|
|
|
|
concurrency: |
|
|
group: pr-${{ github.event.pull_request.number }}-preview |
|
|
cancel-in-progress: true |
|
|
|
|
|
jobs: |
|
|
preview: |
|
|
|
|
|
if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name |
|
|
|
|
|
runs-on: ubuntu-latest |
|
|
|
|
|
steps: |
|
|
|
|
|
- uses: actions/checkout@v4 |
|
|
|
|
|
|
|
|
- uses: ./.github/actions/build-design-system-docs |
|
|
|
|
|
|
|
|
- run: npm install -g wrangler |
|
|
|
|
|
|
|
|
- name: Upload Worker version |
|
|
id: upload |
|
|
env: |
|
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.DESIGN_SYSTEM_PREVIEW_CLOUDFLARE_ACCOUNT }} |
|
|
CLOUDFLARE_API_TOKEN: ${{ secrets.DESIGN_SYSTEM_PREVIEW_CLOUDFLARE_TOKEN }} |
|
|
run: | |
|
|
# Run the upload and tee output so it's visible in the GitHub Actions log |
|
|
OUT=$(wrangler versions upload --cwd apps/design-system-docs 2>&1 | tee /dev/stderr) |
|
|
|
|
|
|
|
|
URL=$(echo "$OUT" | grep -oE 'https://[a-z0-9-]+-preview\.a8cds\.workers\.dev/?') |
|
|
|
|
|
|
|
|
echo "URL: $URL" |
|
|
|
|
|
|
|
|
echo "url=$URL" >> "$GITHUB_OUTPUT" |
|
|
|
|
|
|
|
|
- name: Find preview comment |
|
|
id: find_comment |
|
|
uses: peter-evans/find-comment@v3 |
|
|
with: |
|
|
issue-number: ${{ github.event.pull_request.number }} |
|
|
body-includes: '<!-- cf-preview-comment -->' |
|
|
|
|
|
|
|
|
- name: Comment (create or update) |
|
|
uses: peter-evans/create-or-update-comment@v4 |
|
|
with: |
|
|
issue-number: ${{ github.event.pull_request.number }} |
|
|
comment-id: ${{ steps.find_comment.outputs.comment-id }} |
|
|
edit-mode: replace |
|
|
body: | |
|
|
<!-- cf-preview-comment --> |
|
|
**Design System Reference Site Preview:** |
|
|
|
|
|
${{ steps.upload.outputs.url }} |
|
|
|
|
|
(Latest commit: ${{ github.event.pull_request.head.sha }}) |
|
|
|