Skip to content

Trigger netlify deploy preview through GH action #20

Trigger netlify deploy preview through GH action

Trigger netlify deploy preview through GH action #20

name: trigger Netlify deploy preview
on:
pull_request:
paths: ['sites/docs/**', 'sites/main-site/**']
jobs:
change-detection:
name: 'detect changed sub-sites'
runs-on: ubuntu-latest
steps:
- name: Checkout website repo
uses: actions/checkout@v4
- name: Check changed files
id: changed-files-yaml
uses: tj-actions/changed-files@v44
with:
files_yaml: |
docs:
- sites/docs/**
main-site:
- sites/main-site/**
outputs:
main-site_any_changed: ${{ steps.changed-files-yaml.outputs.main-site_any_changed }}
docs_any_changed: ${{ steps.changed-files-yaml.outputs.docs_any_changed }}
deploy-main-site:
name: 'Deploy preview for main-site'
runs-on: ubuntu-latest
needs: change-detection
if: github.repository == 'nf-core/website' && needs.change-detection.outputs.main-site_any_changed == 'true'
permissions:
pull-requests: write
steps:
- name: Checkout website repo
uses: actions/checkout@v4
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install npm deps
run: npm ci
- name: Build website
run: npm run build --workspace sites/main-site
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: './sites/main-site/dist'
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: 'nf-core/main-site PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}'
alias: nf-core-main-site-pr-${{ github.event.pull_request.number }}
enable-commit-comment: false
enable-commit-status: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_MAIN_SITE_ID }}
timeout-minutes: 1
deploy-docs:
name: 'Deploy preview for docs'
runs-on: ubuntu-latest
needs: change-detection
if: github.repository == 'nf-core/website' && needs.change-detection.outputs.docs_any_changed == 'true'
permissions:
pull-requests: write
steps:
- name: Checkout website repo
uses: actions/checkout@v4
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install npm deps
run: npm ci
- name: Build website
run: npm run build --workspace sites/docs
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: './sites/docs/dist'
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: 'nf-core/docs PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}'
alias: nf-core-docs-pr-${{ github.event.pull_request.number }}
enable-commit-comment: false
enable-commit-status: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DOCS_ID }}
timeout-minutes: 1