Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger netlify deploy preview through GH action #2614

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/netlify-deploy-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
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
3 changes: 2 additions & 1 deletion sites/main-site/src/pages/blog/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const sections: SidebarEntry[] = years.map((year) => {
<a
href={'/blog/' + post.slug}
class:list={[
'post-badge text-decoration-none badge text-bg-primary fs-6 mb-0 rounded-top-0 w-25 m-auto position-absolute top-0 start-0 end-0',
'post-badge text-decoration-none badge text-bg-primary fs-6 mb-0 rounded-top-0 m-auto position-absolute top-0 start-0 end-0',
new Date(Date.now()) > new Date(post.data.pubDate) &&
new Date(post.data.pubDate) >
new Date(Date.now() - 2 * 24 * 60 * 60 * 1000)
Expand Down Expand Up @@ -168,5 +168,6 @@ const sections: SidebarEntry[] = years.map((year) => {
}
.post-badge {
z-index: 10;
width: fit-content;
}
</style>
Loading