Files
upload-pages-artifact/action.yml
T

77 lines
2.3 KiB
YAML
Raw Normal View History

2022-08-10 12:49:12 -05:00
name: "Upload GitHub Pages artifact"
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
default: "_site/"
2022-05-24 11:12:29 -07:00
retention-days:
description: "Duration after which artifact will expire in days."
2022-05-24 11:12:29 -07:00
required: false
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: |
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"
done
2022-05-24 11:12:29 -07:00
tar \
--dereference --hard-dereference \
--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
.
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: |
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"
done
2022-08-09 21:49:27 +03:00
gtar \
--dereference --hard-dereference \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP/artifact.tar" \
2022-08-09 02:25:59 +03:00
--exclude=.git \
--exclude=.github \
.
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 \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP\artifact.tar" \
2022-08-01 06:46:01 -07:00
--exclude=.git \
--exclude=.github \
--force-local \
"."
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 }}