move deploy workflow into workflows/ #1
This file contains hidden or 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: Deploy Documentation | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| deploy: | ||
| description: "Whether to deploy the website to GitHub Pages" | ||
| required: false | ||
| default: false | ||
| # Allow this job to clone the repo and create a page deployment | ||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
| concurrency: | ||
| group: "docs-deploy-${{ github.ref }}" | ||
| cancel-in-progress: true | ||
| jobs: | ||
| parameters-component: | ||
| name: pipeline_parameters | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| repository: scilus/nf-pediatric | ||
| ref: ${{ github.event.pull_request.head.sha || 'main' }} | ||
| path: nf-pediatric | ||
| fetch-depth: 0 # Shallow clones should be disabled for a version bump to work | ||
| - name: Install Nextflow | ||
| uses: nf-core/setup-nextflow@v2 | ||
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | ||
| with: | ||
| python-version: "3.13" | ||
| architecture: "x64" | ||
| - name: read .nf-core.yml | ||
| uses: pietrobolcato/action-read-yaml@9f13718d61111b69f30ab4ac683e67a56d254e1d # 1.1.0 | ||
| id: read_yml | ||
| with: | ||
| config: ${{ github.workspace }}/.nf-core.yml | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install nf-core==${{ steps.read_yml.outputs['nf_core_version'] }} | ||
| - name: Fetch pipeline parameters | ||
| id: pipeline_params | ||
| run: | | ||
| nf-core pipelines schema docs -o parameters.md -x markdown | ||
| echo '---' | cat - parameters.md > temp && mv temp parameters.md | ||
| echo 'title: Pipeline Parameters' | cat - parameters.md > temp && mv temp parameters.md | ||
| echo 'description: nf-pediatric parameters' | cat - parameters.md > temp && mv temp parameters.md | ||
| echo '---' | cat - parameters.md > temp && mv temp parameters.md | ||
| echo '' | cat - parameters.md > temp && mv temp parameters.md | ||
| - name: Pack into artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: markdown | ||
| path: parameters.md | ||
| build: | ||
| needs: parameters-component | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout website code | ||
| uses: actions/checkout@v4 | ||
| - name: Download pipeline parameters | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: markdown | ||
| path: src/content/docs/guides/ | ||
| - name: Install, build, and upload the site | ||
| uses: withastro/action@v2 | ||
| with: | ||
| node-version: 22 | ||
| package-manager: npm@latest | ||
| - name: Upload built site | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: dist | ||
| deploy: | ||
| if: ${{ inputs.deploy == 'true' }} | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||
| preview-deploy: | ||
| if: ${{ inputs.deploy == 'false' && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') }} | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: pr-preview-${{ github.event.pull_request.number }} | ||
| url: ${{ steps.preview.outputs.page_url }} | ||
| steps: | ||
| - name: Deploy PR preview to GitHub Pages | ||
| id: preview | ||
| uses: actions/deploy-pages@v4 | ||
| - name: Comment on PR with preview link | ||
| if: ${{ success() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PREVIEW_URL: ${{ steps.preview.outputs.page_url }} | ||
| run: | | ||
| gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ | ||
| -f body="🚀 **Documentation preview deployed!** | ||
| You can view the live preview here: | ||
| 👉 [${{ env.PREVIEW_URL }}](${{ env.PREVIEW_URL }}) | ||
| _(This preview will be automatically removed when the PR is closed or merged.)_" | ||