Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Steelskin committed Nov 6, 2024
0 parents commit 487f7e1
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Test

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
upload-file:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Create executable file
run: |
echo "#!/bin/bash" > hello.sh
echo "echo 'Hello world!'" >> hello.sh
chmod +x hello.sh
- name: Upload artifact
uses: thebrowsercompany/gha-upload-tar-artifact@main
with:
name: hello-file
path: hello.sh

- name: Delete file
run: rm hello.sh

- name: Download artifact
uses: ./
with:
name: hello-file
path: .

- name: Run executable
run: |
./hello.sh
upload-directory:
runs-on: ubuntu-latest

steps:
- name: Create directory
run: |
mkdir -p hello
echo "Hello world!" > hello/world.txt
echo "#!/bin/bash" > hello/hello.sh
echo "echo 'Hello world!'" >> hello/hello.sh
chmod +x hello/hello.sh
- name: Upload artifact
uses: thebrowsercompany/gha-upload-tar-artifact@main
with:
name: hello-dir
path: hello/

- name: Delete directory
run: rm -rf hello

- name: Download artifact
uses: ./
with:
name: hello-dir
path: .

- name: Check permissions
run: |
./hello/hello.sh && ! test -x hello/world.txt
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2024, The Browser Company of New York
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# `@thebrowsercompany/gha-download-tar-artifact`

Download and untar [Action Artifacts](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) from your Workflow Runs. Internally powered by GitHub's [@actions/download-artifact](https://github.com/actions/download-artifact) action. This action uses [@actions/download-artifact](https://github.com/actions/download-artifact) to download the tar file and untar it, preserving permissions on non-Windows platforms.

See also [gha-upload-tar-artifact](https://github.com/thebrowsercompany/gha-upload-tar-artifact). For further documentation, refer to the [@actions/download-artifact](https://github.com/actions/download-artifact) documentation.

- [`@thebrowsercompany/gha-download-tar-artifact`](#thebrowsercompanygha-download-tar-artifact)
- [Usage](#usage)
- [Inputs](#inputs)
- [Outputs](#outputs)

## Usage

### Inputs

```yaml
- uses: thebrowsercompany/gha-upload-tar-artifact@main
with:
# Name of the artifact to download. If unspecified, defaults to `artifact`.
name:

# Destination path.
# Required.
path:
```
### Outputs
| Name | Description | Example |
| - | - | - |
| Name | Description | Example |
| - | - | - |
| `download-path` | Absolute path where the artifact(s) were downloaded | `/tmp/my/download/path` |
50 changes: 50 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 'Download and untar an artifact, preserving permissions'
description: 'Download a build artifact that was previously uploaded in the workflow by the gha-upload-tar-artifact action, with permissions preserved.'
author: 'The Browser Company of New York'

inputs:
name:
description: 'The name of the artifact to download.'
default: 'artifact'
required: true
path:
description: 'Destination path. Defaults to $GITHUB_WORKSPACE.'
default: ${{ github.workspace }}

outputs:
download-path:
description: 'Path of artifact download'

runs:
using: composite

steps:
- name: Create Temporary Directory
shell: pwsh
id: create-temp-dir
run: |
$TempDir = New-TemporaryFile | % { Remove-Item $_; New-Item -ItemType Directory -Path $_ }
echo "temp-dir=$TempDir" >> $env:GITHUB_OUTPUT
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.name }}
path: ${{ steps.create-temp-dir.outputs.temp-dir }}

- name: Extract Tar Archive
shell: pwsh
id: extract-tar
run: |
New-Item -ItemType Directory -Path "${{ inputs.path }}" -Force | Out-Null
$TarFile = Join-Path "${{ steps.create-temp-dir.outputs.temp-dir }}" "${{ inputs.name }}.tar"
tar xf $TarFile -C ${{ inputs.path }}
- name: Delete Temporary Directory
shell: pwsh
run: Remove-Item -Recurse ${{ steps.create-temp-dir.outputs.temp-dir }}

- name: Export Output
shell: pwsh
run: |
Write-Output "download-path=${{ inputs.path }}" >> $env:GITHUB_OUTPUT

0 comments on commit 487f7e1

Please sign in to comment.