Skip to content

Commit

Permalink
Fix handling of the destination input (#2)
Browse files Browse the repository at this point in the history
* Add CI workflows to test the `destination` input

* Fix syntax error

* Try to fix destination path cleanup

* Try to fix uploading of shrunken image based on destination in CI test

* Try to fix name collision in GitHub job artifacts upload

* Bump version numbers in `README.md`
  • Loading branch information
ethanjli authored May 27, 2024
1 parent fd333c6 commit 24627d0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/test-pishrink.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ on:

jobs:
build:
name: Build image
name: Build test image
strategy:
fail-fast: false
matrix:
destination:
- name: implicit
path: ''
- name: explicit
path: 'destination.img'
- name: explicit-gz
path: 'destination.img.gz'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -41,17 +51,19 @@ jobs:
pifile: cowsay.Pifile

- name: Shrink the image
id: shrink-image
uses: ./
with:
image: cowsay-image.img
destination: ${{ matrix.destination.path }}
compress: gzip
compress-parallel: true

- name: Upload image to Job Artifacts
uses: actions/upload-artifact@v4
with:
name: rpi-cowsay-arm64-latest
path: cowsay-image.img.gz
name: rpi-cowsay-${{ matrix.destination.name }}-arm64-latest
path: ${{ steps.shrink-image.outputs.destination }}
if-no-files-found: error
retention-days: 0
compression-level: 0
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PiShrink GitHub Action

GitHub action to run [PiShrink](https://github.com/Drewsif/PiShrink) on a Raspberry Pi SD card image.
GitHub action to process a Raspberry Pi SD card image using [PiShrink](https://github.com/Drewsif/PiShrink).

## Basic Usage Examples

Expand All @@ -16,7 +16,7 @@ downloading a base image, expanding it, and modifying its filesystem (e.g. with
run: wget http://some-website.com/large-rpi-sd-card-image.img

- name: Shrink image
uses: ethanjli/pishrink-action@v0.1.0
uses: ethanjli/pishrink-action@v0.1.1
with:
image: large-rpi-sd-card-image.img
compress: gzip
Expand All @@ -38,7 +38,7 @@ downloading a base image, expanding it, and modifying its filesystem (e.g. with
run: wget http://some-website.com/large-rpi-sd-card-image.img

- name: Shrink image
uses: ethanjli/pishrink-action@v0.1.0
uses: ethanjli/pishrink-action@v0.1.1
with:
image: large-rpi-sd-card-image.img
compress: xz
Expand All @@ -60,7 +60,7 @@ downloading a base image, expanding it, and modifying its filesystem (e.g. with
run: wget http://some-website.com/large-rpi-sd-card-image.img

- name: Shrink image
uses: ethanjli/pishrink-action@v0.1.0
uses: ethanjli/pishrink-action@v0.1.1
with:
image: large-rpi-sd-card-image.img
destination: result.img.gz
Expand All @@ -85,7 +85,7 @@ downloading a base image, expanding it, and modifying its filesystem (e.g. with

- name: Shrink image
id: shrink-image
uses: ethanjli/pishrink-action@v0.1.0
uses: ethanjli/pishrink-action@v0.1.1
with:
image: large-rpi-sd-card-image.img
compress: gzip
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
pifile: cowsay.Pifile

- name: Shrink the image
uses: ethanjli/pishrink-action@v0.1.0
uses: ethanjli/pishrink-action@v0.1.1
with:
image: cowsay-image.img
compress: gzip
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ runs:
gzip | gz)
flags="$flags -z"
if [ ! -z "${{ inputs.destination }}" ]; then
destination="$(sed 's~\.gz$~~' "${{ inputs.destination }}")"
destination="$(echo "${{ inputs.destination }}" | sed -e 's~\.gz$~~')"
echo "destination=$destination.gz" >> $GITHUB_OUTPUT
else
echo "destination=${{ inputs.image }}.gz" >> $GITHUB_OUTPUT
Expand All @@ -66,7 +66,7 @@ runs:
xz)
flags="$flags -Z"
if [ ! -z "${{ inputs.destination }}" ]; then
destination="$(sed 's~\.xz$~~' "${{ inputs.destination }}")"
destination="$(echo "${{ inputs.destination }}" | sed -e 's~\.xz$~~')"
echo "destination=$destination.xz" >> $GITHUB_OUTPUT
else
echo "destination=${{ inputs.image }}.xz" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit 24627d0

Please sign in to comment.