Add workflow #1
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: publish-site | |
description: "Publish static assets to GitHub Pages" | |
inputs: | |
name: | |
description: 'Artifact name' | |
required: false | |
default: 'github-pages' | |
path: | |
description: "Path of the directory containing the static assets." | |
required: true | |
default: "docs/" | |
retention-days: | |
description: "Duration after which artifact will expire in days." | |
required: false | |
default: "1" | |
outputs: | |
artifact_id: | |
description: "The ID of the artifact that was uploaded." | |
value: ${{ steps.upload-artifact.outputs.artifact-id }} | |
runs: | |
using: composite | |
steps: | |
- name: Archive artifact | |
shell: sh | |
if: runner.os == 'Linux' | |
run: | | |
echo ::group::Archive artifact | |
tar \ | |
--dereference --hard-dereference \ | |
--directory "$INPUT_PATH" \ | |
-cvf "$RUNNER_TEMP/artifact.tar" \ | |
--exclude=.git \ | |
--exclude=.github \ | |
. | |
echo ::endgroup:: | |
env: | |
INPUT_PATH: ${{ inputs.path }} | |
# Switch to gtar (GNU tar instead of bsdtar which is the default in the MacOS runners so we can use --hard-dereference) | |
- name: Archive artifact | |
shell: sh | |
if: runner.os == 'macOS' | |
run: | | |
echo ::group::Archive artifact | |
gtar \ | |
--dereference --hard-dereference \ | |
--directory "$INPUT_PATH" \ | |
-cvf "$RUNNER_TEMP/artifact.tar" \ | |
--exclude=.git \ | |
--exclude=.github \ | |
. | |
echo ::endgroup:: | |
env: | |
INPUT_PATH: ${{ inputs.path }} | |
# Massage the paths for Windows only | |
- name: Archive artifact | |
shell: bash | |
if: runner.os == 'Windows' | |
run: | | |
echo ::group::Archive artifact | |
tar \ | |
--dereference --hard-dereference \ | |
--directory "$INPUT_PATH" \ | |
-cvf "$RUNNER_TEMP\artifact.tar" \ | |
--exclude=.git \ | |
--exclude=.github \ | |
--force-local \ | |
"." | |
echo ::endgroup:: | |
env: | |
INPUT_PATH: ${{ inputs.path }} | |
- name: Upload artifact | |
id: upload-artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ inputs.name }} | |
path: ${{ runner.temp }}/artifact.tar | |
retention-days: ${{ inputs.retention-days }} | |
if-no-files-found: error |