Build and Deploy #10
This file contains 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: "Build and Deploy" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
on: | |
workflow_dispatch: | |
inputs: | |
theme: | |
type: string | |
description: "Theme to use for building website and/or PDF document (jsonresume-theme-<theme>)" | |
required: true | |
default: macchiato-plus | |
build-website: | |
type: boolean | |
description: "Whether to build the website and create artifact or not" | |
required: true | |
default: true | |
deploy-website: | |
type: boolean | |
description: "Whether to deploy the website or not" | |
required: true | |
default: false | |
build-pdf: | |
type: boolean | |
description: "Whether to build PDF document and create artifact or not" | |
required: true | |
default: true | |
node-version: | |
type: string | |
description: "NodeJS version to use" | |
required: false | |
default: "lts/*" | |
pnpm-version: | |
type: string | |
description: "PNPM version to use" | |
required: false | |
default: "9" | |
chrome-version: | |
type: string | |
description: "Chrome version to use" | |
required: false | |
default: "stable" | |
env: | |
website-key: website-${{ github.sha }} | |
pdf-key: pdf-${{ github.sha }} | |
web-directory: dist/web | |
pdf-path: dist/pdf | |
full-theme-name: jsonresume-theme-${{ inputs.theme }} | |
jobs: | |
build: | |
if: ${{ inputs.build-website || inputs.build-pdf }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup tooling | |
id: setup-tooling | |
uses: ./.github/actions/setup-tooling | |
with: | |
node-version: ${{ inputs.node-version }} | |
pnpm-version: ${{ inputs.pnpm-version }} | |
use-chrome: ${{ inputs.build-pdf }} | |
chrome-version: ${{ inputs.chrome-version }} | |
- name: Install selected theme | |
run: pnpm install -D ${{ env.full-theme-name }} | |
- name: Build website | |
if: ${{ inputs.build-website || inputs.build-pdf }} | |
env: | |
THEME: ${{ env.full-theme-name }} | |
run: pnpm run build-web | |
- name: Create artifact for web | |
if: ${{ inputs.build-website }} | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
name: ${{ env.website-key }} | |
path: ${{ env.web-directory }} | |
- name: Build PDF | |
env: | |
PUPPETEER_BROWSER_REVISION: ${{ steps.setup-tooling.outputs.chrome-version }} | |
PUPPETEER_EXECUTABLE_PATH: ${{ steps.setup-tooling.outputs.chrome-path }} | |
if: ${{ inputs.build-pdf }} | |
run: pnpm run create-pdf | |
- name: Create artifact for PDF | |
if: ${{ inputs.build-pdf }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.pdf-key }} | |
path: ${{ env.pdf-path }} | |
deploy: | |
needs: build | |
if: ${{ inputs.deploy-website && inputs.build-website }} | |
runs-on: ubuntu-latest | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
with: | |
artifact_name: ${{ env.website-key }} |