Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add globbing to inputs.path #29

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ A composite Action for packaging and uploading artifact that can be deployed to

# Usage

See [action.yml](action.yml)
## Upload GitHub Pages artifact

```yaml
steps:
- name: Upload github-pages artifact
uses: actions/upload-pages-artifact@v1
with:
path: '.'
files: '*/**.html'
```
*path* must be a path to a directory, and *files* must be a valid glob pattern.

<!-- TODO: document custom workflow -->

Expand Down
24 changes: 14 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ description: "A composite action that prepares your static assets to be deployed
author: "GitHub"
inputs:
path:
description: "Path of the directory containing the static assets."
description: "A directory containing the static assets."
required: true
default: "_site/"
files:
description: "A glob pattern describing the static assets."
required: false
default: "."
retention-days:
description: "Duration after which artifact will expire in days."
required: false
Expand All @@ -17,46 +21,46 @@ runs:
shell: bash
if: runner.os == 'Linux'
run: |
shopt -s globstar && \
tar \
--dereference --hard-dereference \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
.
"$INPUT_FILES"
env:
INPUT_PATH: ${{ inputs.path }}
INPUT_FILES: ${{ inputs.files }}

# 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: |
shopt -s globstar && \
gtar \
--dereference --hard-dereference \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP/artifact.tar" \
--exclude=.git \
--exclude=.github \
.
"$INPUT_FILES"
env:
INPUT_PATH: ${{ inputs.path }}
INPUT_FILES: ${{ inputs.files }}

# Massage the paths for Windows only
- name: Archive artifact
shell: bash
if: runner.os == 'Windows'
run: |
shopt -s globstar && \
tar \
--dereference --hard-dereference \
--directory "$INPUT_PATH" \
-cvf "$RUNNER_TEMP\artifact.tar" \
--exclude=.git \
--exclude=.github \
--force-local \
"."
"$INPUT_FILES"
env:
INPUT_PATH: ${{ inputs.path }}
INPUT_FILES: ${{ inputs.files }}

- name: Upload artifact
uses: actions/upload-artifact@main
Expand Down