Skip to content

Update actions

Update actions #780

Workflow file for this run

# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:
name: pkgdown
jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v6
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: yihui/actions/setup-r-dependencies@HEAD
with:
extra-packages: pkgdown rstudio/quillt .
- name: Build pkgdown site
run: pkgdown::build_site(new_process = FALSE, install = FALSE)
shell: Rscript {0}
- name: Deploy to Netlify
id: netlify-deploy
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
DEPLOY_OUTPUT=$(npx --yes netlify-cli deploy \
--dir=reference --prod --no-build \
--message "Deploy from GHA: $GITHUB_SHA")
else
DEPLOY_OUTPUT=$(npx --yes netlify-cli deploy \
--dir=reference \
--alias="deploy-preview-${{ github.event.number }}" \
--no-build \
--message "Deploy from GHA: $GITHUB_SHA")
fi
echo "$DEPLOY_OUTPUT"
DEPLOY_URL=$(echo "$DEPLOY_OUTPUT" | grep -oP 'https://[^\s>]+\.netlify\.app' | head -1)
echo "url=$DEPLOY_URL" >> "$GITHUB_OUTPUT"
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Set commit status
if: always()
uses: actions/github-script@v8
with:
script: |
const outcome = '${{ steps.netlify-deploy.outcome }}';
const deployUrl = '${{ steps.netlify-deploy.outputs.url }}';
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: outcome === 'success' ? 'success' : 'failure',
target_url: deployUrl || undefined,
description: outcome === 'success' ? 'Deploy preview ready' : 'Deploy failed',
context: 'netlify/deploy'
});
- name: Comment deploy URL on PR
if: github.event_name == 'pull_request' && steps.netlify-deploy.outcome == 'success'
uses: actions/github-script@v8
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `🚀 Netlify deploy preview: ${{ steps.netlify-deploy.outputs.url }}`
});