2022-08-10 12:49:12 -05:00
|
|
|
name: "Upload GitHub Pages artifact"
|
2022-07-13 11:47:37 -07:00
|
|
|
description: "A composite action that prepares your static assets to be deployed to GitHub Pages"
|
2022-08-10 13:59:28 -05:00
|
|
|
author: "GitHub"
|
2022-05-10 22:02:28 -04:00
|
|
|
inputs:
|
2022-12-05 03:31:49 +02:00
|
|
|
name:
|
|
|
|
|
description: 'Artifact name'
|
|
|
|
|
required: false
|
|
|
|
|
default: 'github-pages'
|
2022-05-24 11:12:29 -07:00
|
|
|
path:
|
2022-08-03 08:05:15 -07:00
|
|
|
description: "Path of the directory containing the static assets."
|
2022-05-10 22:02:28 -04:00
|
|
|
required: true
|
2022-07-13 11:47:37 -07:00
|
|
|
default: "_site/"
|
2022-05-24 11:12:29 -07:00
|
|
|
retention-days:
|
2022-07-13 11:47:37 -07:00
|
|
|
description: "Duration after which artifact will expire in days."
|
2022-05-24 11:12:29 -07:00
|
|
|
required: false
|
2022-07-13 11:47:37 -07:00
|
|
|
default: "1"
|
2022-05-10 22:02:28 -04:00
|
|
|
runs:
|
2022-05-24 11:12:29 -07:00
|
|
|
using: composite
|
|
|
|
|
steps:
|
|
|
|
|
- name: Archive artifact
|
2022-08-17 00:04:43 +02:00
|
|
|
shell: sh
|
2022-08-09 02:25:59 +03:00
|
|
|
if: runner.os == 'Linux'
|
2022-05-24 14:30:41 -07:00
|
|
|
run: |
|
2022-12-16 12:44:24 +08:00
|
|
|
chmod -c -R +rX "$INPUT_PATH" | while read line; do
|
2022-12-08 14:48:49 -08:00
|
|
|
echo "::warning title=Invalid file permissions automatically fixed::$line"
|
2022-11-08 10:33:02 -05:00
|
|
|
done
|
2022-05-24 11:12:29 -07:00
|
|
|
tar \
|
|
|
|
|
--dereference --hard-dereference \
|
2022-08-27 12:42:58 -07:00
|
|
|
--directory "$INPUT_PATH" \
|
|
|
|
|
-cvf "$RUNNER_TEMP/artifact.tar" \
|
2022-05-24 11:12:29 -07:00
|
|
|
--exclude=.git \
|
2022-07-13 11:56:17 -07:00
|
|
|
--exclude=.github \
|
2022-05-24 11:12:29 -07:00
|
|
|
.
|
2022-08-27 12:42:58 -07:00
|
|
|
env:
|
|
|
|
|
INPUT_PATH: ${{ inputs.path }}
|
2022-08-01 06:46:01 -07:00
|
|
|
|
2022-08-09 21:49:27 +03:00
|
|
|
# Switch to gtar (GNU tar instead of bsdtar which is the default in the MacOS runners so we can use --hard-dereference)
|
2022-08-09 02:25:59 +03:00
|
|
|
- name: Archive artifact
|
2022-08-17 00:04:43 +02:00
|
|
|
shell: sh
|
2022-08-09 02:25:59 +03:00
|
|
|
if: runner.os == 'macOS'
|
|
|
|
|
run: |
|
2022-12-16 12:44:24 +08:00
|
|
|
chmod -v -R +rX "$INPUT_PATH" | while read line; do
|
2022-12-08 14:48:49 -08:00
|
|
|
echo "::warning title=Invalid file permissions automatically fixed::$line"
|
2022-11-08 10:33:02 -05:00
|
|
|
done
|
2022-08-09 21:49:27 +03:00
|
|
|
gtar \
|
|
|
|
|
--dereference --hard-dereference \
|
2022-08-27 12:42:58 -07:00
|
|
|
--directory "$INPUT_PATH" \
|
|
|
|
|
-cvf "$RUNNER_TEMP/artifact.tar" \
|
2022-08-09 02:25:59 +03:00
|
|
|
--exclude=.git \
|
|
|
|
|
--exclude=.github \
|
|
|
|
|
.
|
2022-08-27 12:42:58 -07:00
|
|
|
env:
|
|
|
|
|
INPUT_PATH: ${{ inputs.path }}
|
2022-08-09 02:25:59 +03:00
|
|
|
|
2022-08-01 06:46:01 -07:00
|
|
|
# Massage the paths for Windows only
|
|
|
|
|
- name: Archive artifact
|
|
|
|
|
shell: bash
|
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
|
run: |
|
|
|
|
|
tar \
|
|
|
|
|
--dereference --hard-dereference \
|
2022-08-27 12:42:58 -07:00
|
|
|
--directory "$INPUT_PATH" \
|
|
|
|
|
-cvf "$RUNNER_TEMP\artifact.tar" \
|
2022-08-01 06:46:01 -07:00
|
|
|
--exclude=.git \
|
|
|
|
|
--exclude=.github \
|
|
|
|
|
--force-local \
|
|
|
|
|
"."
|
2022-08-27 12:42:58 -07:00
|
|
|
env:
|
|
|
|
|
INPUT_PATH: ${{ inputs.path }}
|
2022-08-01 06:46:01 -07:00
|
|
|
|
2022-05-10 22:02:28 -04:00
|
|
|
- name: Upload artifact
|
|
|
|
|
uses: actions/upload-artifact@main
|
|
|
|
|
with:
|
2022-12-05 03:31:49 +02:00
|
|
|
name: ${{ inputs.name }}
|
2022-05-24 11:12:29 -07:00
|
|
|
path: ${{ runner.temp }}/artifact.tar
|
|
|
|
|
retention-days: ${{ inputs.retention-days }}
|