Skip to content

Publish to Netlify

Publish to Netlify #47

Workflow file for this run

name: GitHub Pages
on:
pull_request:
push:
workflow_dispatch:
inputs:
publish_gh_pages:
type: boolean
description: 'Publish GH Page'
default: false
jobs:
build-artifacts:
uses: ./.github/workflows/build-artifacts.yml
with:
# SonarQube requires JDK 17 or higher
java-version: '17'
pages:
needs: build-artifacts
runs-on: ubuntu-latest
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
env:
DTC_HEADLESS: true
steps:
- name: Install dot (Graphviz)
run: |
sudo apt-get update
sudo apt-get install -y graphviz
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: "${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}"
restore-keys: ${{ runner.os }}-gradle
- name: Cache .doctoolchain
uses: actions/cache@v2
with:
path: ~/.doctoolchain
key: "${{ runner.os }}-doctoolchain-${{ hashFiles('**/lockfiles') }}"
restore-keys: ${{ runner.os }}-doctoolchain
- name: Check out
uses: actions/checkout@v2
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: .
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Generate Pages
run: ./generate-pages
- name: Upload Artifacts
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: public
retention-days: 7
publish-to-github:
runs-on: ubuntu-latest
needs: pages
if: ${{ github.event.inputs.publish_gh_pages }}
steps:
- name: Download GitHub Pages Artifact
uses: actions/download-artifact@v4
with:
name: github-pages
path: public
- name: Deploy Pages
uses: actions/deploy-pages@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
publish-to-netlify:
runs-on: ubuntu-latest
needs: pages
environment: netlify
if: ${{ !github.event.inputs.publish_gh_pages }}
steps:
- name: Download GitHub Pages Artifact
uses: actions/download-artifact@v4
with:
name: github-pages
path: public
- name: Cache Netlify CLI
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-netlify-cli-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-netlify-cli
- name: Deploy to Netlify
uses: South-Paw/action-netlify-cli@v2
id: netlify
with:
# be sure to escape any double quotes with a backslash
args: 'deploy --json --dir ./public --message \"draft [${{ github.sha }}]\"'
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}