Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Steelskin committed Nov 5, 2024
0 parents commit 2f37365
Show file tree
Hide file tree
Showing 4 changed files with 152 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
path: hello.sh

- name: Delete file
run: rm hello.sh

- name: Download artifact
uses: ./
with:
name: hello
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
path: hello/

- name: Delete directory
run: rm -rf hello

- name: Download artifact
uses: ./
with:
name: hello
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.
Empty file added README.md
Empty file.
52 changes: 52 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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

defaults:
run:
shell: pwsh

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
run: Remove-Item -Recurse ${{ steps.create-tar.outputs.temp-dir }}

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

0 comments on commit 2f37365

Please sign in to comment.