Trigger netlify deploy preview through GH action #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: trigger Netlify deploy preview | |
on: | |
pull_request: | |
paths: ['sites/docs/**', 'sites/main-site/**'] | |
jobs: | |
pre-build: | |
name: 'prepare build setup' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./website | |
steps: | |
- name: Checkout website repo | |
uses: actions/checkout@v4 | |
with: | |
path: ./website | |
- name: debug | |
run: | | |
ls -l . | |
ls -l .. | |
pwd | |
- name: Set up Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
cache-dependency-path: ./website/package-lock.json | |
- name: Install npm deps | |
run: npm ci | |
- name: debug | |
run: | | |
ls -l . | |
ls -l .. | |
pwd | |
git status | |
- name: get changed sub-site | |
id: get_changed_subsite | |
run: | | |
CHANGED_DIRECTORY=$(git diff --name-only ${{ github.base_ref }}...HEAD | grep -E 'sites/(main-site|docs)' | head -n1 | cut -d'/' -f2) | |
outputs: | |
changed_directory: ${{ env.CHANGED_DIRECTORY }} | |
deploy-main-site: | |
name: 'Deploy preview for main-site' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./website | |
needs: pre-build | |
if: github.repository == 'nf-core/website' && needs.pre-build.outputs.changed_directory == 'main-site' | |
permissions: | |
pull-requests: write | |
steps: | |
- 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 | |
defaults: | |
run: | |
working-directory: ./website | |
needs: pre-build | |
if: github.repository == 'nf-core/website' && needs.pre-build.outputs.changed_directory == 'docs' | |
permissions: | |
pull-requests: write | |
steps: | |
- 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 |