Skip to content

Commit

Permalink
Fix up and add dry-run to site workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgrimm committed Oct 9, 2023
1 parent b3a8476 commit 4d41dca
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 42 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/perform-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ jobs:
permissions:
contents: write

secrets: inherit

needs:
- maven-build-deploy

Expand Down Expand Up @@ -196,4 +194,5 @@ jobs:

uses: ./.github/workflows/render-and-deploy-site.yml
with:
git-ref: ${{ needs.maven-build-deploy.outputs.release-sha }}
git-ref: ${{ needs.maven-build-deploy.outputs.release-tag }}
dry-run: ${{ inputs.dry-run }}
110 changes: 71 additions & 39 deletions .github/workflows/render-and-deploy-site.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
name: Generate Site and Deploy to GitHub Pages

on:
workflow_call:
workflow_dispatch:
inputs:
git-ref:
description: Git Ref
required: true
type: string
workflow_dispatch:
dry-run:
description: Dry Run
required: false
type: boolean
default: false
workflow_call:
inputs:
git-ref:
required: true
type: string
dry-run:
required: false
type: boolean
default: false

jobs:
render-site:
Expand All @@ -23,55 +33,77 @@ jobs:
id-token: write

steps:
- name: Checkout 3scale CMS
uses: actions/checkout@v3
with:
ref: ${{ inputs.git-ref }}

- name: Set Up JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: temurin
cache: maven
settings-path: ${{ github.workspace }}
server-id: github

- name: Set Up Pages
uses: actions/configure-pages@v2

- name: Run Maven Site
# compile needs to run so Maven figures out cross-module dependencies
# and stagingDirectory will have a value appended relative to parent for each module
run: >-
./mvnw
--settings ${{ github.workspace }}/settings.xml
--batch-mode
compile
post-site
site:stage
-DstagingDirectory=${{ github.workspace }}/target/staging/parent
- name: Upload artifacts
uses: actions/upload-pages-artifact@v1
with:
path: ${{ github.workspace }}/target/staging/.
- name: Checkout 3scale CMS
uses: actions/checkout@v4
with:
ref: ${{ inputs.git-ref }}

- name: Set Up JDK
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: '17'
settings-path: ${{ github.workspace }}
server-id: github

- name: Determine Home Directory
id: find-home
run: |
echo "home=$HOME" >> $GITHUB_OUTPUT
- name: Cache Maven Local Repo
uses: actions/cache@v3
with:
path: ${{ steps.find-home.outputs.home }}/.m2/repository
key: ${{ runner.os }}-${{ runner.arch }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-maven-
- name: Set Up Maven Repo Filters
run: |
mkdir -p ${{ steps.find-home.outputs.home }}/.m2/repository/.remoteRepositoryFilters/
cp -av ${{ github.workspace }}/.mvn/filters/*.txt ${{ steps.find-home.outputs.home }}/.m2/repository/.remoteRepositoryFilters/
- name: Set Up Pages
uses: actions/configure-pages@v3
if: ${{ success() && !inputs.dry-run }}

- name: Run Maven Site
# compile needs to run so Maven figures out cross-module dependencies
# and stagingDirectory will have a value appended relative to parent for each module
run: >-
./mvnw
--settings ${{ github.workspace }}/settings.xml
--batch-mode
compile
post-site
site:stage
-DstagingDirectory=${{ github.workspace }}/target/staging/parent
- name: Upload Site Artifacts
uses: actions/upload-pages-artifact@v2
if: ${{ success() && !inputs.dry-run }}
with:
path: ${{ github.workspace }}/target/staging

deploy-site:
name: Deploy Site to GitHub Pages
runs-on: ubuntu-latest

if: ${{ success() && !inputs.dry-run }}

permissions:
pages: write
id-token: write

needs:
- render-site
- render-site

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

0 comments on commit 4d41dca

Please sign in to comment.