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 an option to exclude files from the tar archive #27

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: 'site'
exclude: '*/**.tmp'
```
*path* must be a directory, and *exclude* must be a valid glob pattern.

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

Expand Down
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,55 @@ 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 \
--exclude="$INPUT_EXCLUDE" \
.
env:
INPUT_PATH: ${{ inputs.path }}
INPUT_EXCLUDE: ${{ inputs.exclude }}

# 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 \
--exclude="$INPUT_EXCLUDE" \
.
env:
INPUT_PATH: ${{ inputs.path }}
INPUT_EXCLUDE: ${{ inputs.exclude }}

# 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 \
--exclude="$INPUT_EXCLUDE" \
--force-local \
"."
env:
INPUT_PATH: ${{ inputs.path }}
INPUT_EXCLUDE: ${{ inputs.exclude }}

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