Files
upload-pages-artifact/action.yml
James M. Greene 16e781d8a4 Update action.yml
2022-08-10 12:49:12 -05:00

60 lines
1.7 KiB
YAML

name: "Upload GitHub Pages artifact"
description: "A composite action that prepares your static assets to be deployed to GitHub Pages"
inputs:
path:
description: "Path of the directory containing the static assets."
required: true
default: "_site/"
retention-days:
description: "Duration after which artifact will expire in days."
required: false
default: "1"
runs:
using: composite
steps:
- name: Archive artifact
shell: bash
if: runner.os == 'Linux'
run: |
tar \
--dereference --hard-dereference \
--directory ${{ inputs.path }} \
-cvf ${{ runner.temp }}/artifact.tar \
--exclude=.git \
--exclude=.github \
.
# 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: bash
if: runner.os == 'macOS'
run: |
gtar \
--dereference --hard-dereference \
--directory ${{ inputs.path }} \
-cvf ${{ runner.temp }}/artifact.tar \
--exclude=.git \
--exclude=.github \
.
# Massage the paths for Windows only
- name: Archive artifact
shell: bash
if: runner.os == 'Windows'
run: |
tar \
--dereference --hard-dereference \
--directory "${{ inputs.path }}" \
-cvf "${{ runner.temp }}\artifact.tar" \
--exclude=.git \
--exclude=.github \
--force-local \
"."
- name: Upload artifact
uses: actions/upload-artifact@main
with:
name: github-pages
path: ${{ runner.temp }}/artifact.tar
retention-days: ${{ inputs.retention-days }}