Skip to content

Commit

Permalink
WIP 332 Separate Site generation and publication ...
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Aug 15, 2024
1 parent 7d3d407 commit 82ef310
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 162 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/generate-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Generate Site

on:
pull_request:
push:
workflow_dispatch:

jobs:
build-artifacts:
uses: ./.github/workflows/build-artifacts.yml
with:
# SonarQube requires JDK 17 or higher
java-version: '17'

generate-site:
needs: build-artifacts
runs-on: ubuntu-latest
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}-${{ inputs.publish_gh_pages }}"
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@v4
with:
path: ~/.doctoolchain
key: "${{ runner.os }}-doctoolchain-${{ hashFiles('**/lockfiles') }}"
restore-keys: ${{ runner.os }}-doctoolchain

- name: Check out
uses: actions/checkout@v4

- 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 Site
run: ./generate-pages

- name: 'Publish Test Results'
uses: EnricoMi/publish-unit-test-result-action/linux@v2
if: always()
with:
files: |
**/build/test-results/**/*.xml
- name: Upload Generated Site
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: public
retention-days: 7
162 changes: 0 additions & 162 deletions .github/workflows/gh-pages.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/publish-site-to-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish GitHub Pages

on:
workflow_dispatch:

jobs:
publish-to-github:
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Configure Pages
uses: actions/configure-pages@v5

- name: Deploy Pages
id: deployment
uses: actions/deploy-pages@v4
49 changes: 49 additions & 0 deletions .github/workflows/publish-to-netlify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish to Netlify

on:
workflow_dispatch:

jobs:
publish-to-netlify:
runs-on: ubuntu-latest
environment:
name: netlify
url: ${{ steps.netlify-status.outputs.NETLIFY_DEPLOY_URL }}
steps:
- name: Download Generated Site Artifact
uses: actions/download-artifact@v4
with:
name: github-pages
path: download

- name: Unpack Generated Site
run: |
mkdir -p public
tar -x -C public -v -f download/artifact.tar
- 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:
args: deploy --dir ./public --message 'draft [${{ github.sha }}]' --json
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

- name: Get Netlify Preview URL
id: netlify-status
run: |
echo "NETLIFY_DEPLOY_URL=${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).deploy_url }}" >> $GITHUB_OUTPUT
echo "The URL where the logs from the deployment can be found"
echo "${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).logs }}"
echo ""
echo "the URL of the draft site that Netlify provides"
echo "${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).deploy_url }}/"

0 comments on commit 82ef310

Please sign in to comment.