Skip to content

fix(ci): use workflow_run #111

fix(ci): use workflow_run

fix(ci): use workflow_run #111

name: Build Previewing Docs

Check failure on line 1 in .github/workflows/preview-docs-deployment.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/preview-docs-deployment.yaml

Invalid workflow file

Workflow 'Build Previewing Docs' cannot listen to itself.
on:
workflow_run:
workflows:
- Build Previewing Docs
types:
- completed
jobs:
on-success:
name: Deploy to Netlify
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download artifact - Ubuntu
uses: dawidd6/action-download-artifact@v3
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: docs-ubuntu-latest-build
path: docs-ubuntu-latest-build
allow_forks: true
- name: Download artifact - Windows
uses: dawidd6/action-download-artifact@v3
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: docs-windows-latest-build
path: docs-windows-latest-build
allow_forks: true
- name: Install Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
run_install: false
version: 8
- name: Obtain pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Obtain pnpm store cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Netlify CLI
run: pnpm install -g netlify-cli
- name: Debug
run:
ls -la
ls -la docs-ubuntu-latest-build
ls -la docs-windows-latest-build
- name: Push to Netlify - Ubuntu
id: netlify-ubuntu-latest
timeout-minutes: 10
run: |
NETLIFY_JSON_OUTPUT=$(netlify deploy --dir docs-ubuntu-latest --json)
echo $NETLIFY_JSON_OUTPUT
echo "NETLIFY_JSON_OUTPUT=$(echo $NETLIFY_JSON_OUTPUT)" >> $GITHUB_ENV
echo "NETLIFY_URL=$(echo $NETLIFY_JSON_OUTPUT | jq -r .deploy_url)" >> $GITHUB_ENV
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Push to Netlify - Windows
id: netlify-windows-latest
timeout-minutes: 10
run: |
NETLIFY_JSON_OUTPUT=$(netlify deploy --dir docs-windows-latest-build --json)
echo $NETLIFY_JSON_OUTPUT
echo "NETLIFY_JSON_OUTPUT=$(echo $NETLIFY_JSON_OUTPUT)" >> $GITHUB_ENV
echo "NETLIFY_URL=$(echo $NETLIFY_JSON_OUTPUT | jq -r .deploy_url)" >> $GITHUB_ENV
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: to Netlify
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## ✅ Deployed to deploy to Netlify
| Platform | Status | URL |
|----------|-------------|---------------------------------------------------------|
| Windows | Success | ${{ steps.netlify-ubuntu-latest.outputs.NETLIFY_URL }} |
| Unix | Success | ${{ steps.netlify-windows-latest.outputs.NETLIFY_URL }} |
edit-mode: replace
on-failure:
name: Failed to build previewing docs
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: to Netlify
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## ❌ Failed to deploy to Netlify
| Platform | Status | URL |
|----------|-------------|-------------------------------------------------------|
| Windows | Failed | Please check the status and logs of the workflow run. |
| Unix | Failed | Please check the status and logs of the workflow run. |
edit-mode: replace