Skip to content

Commit

Permalink
Make a GitHub Actions workflow to test the action with Pimod (#1)
Browse files Browse the repository at this point in the history
* Make a GitHub Actions workflow to test the action with Pimod

* Troubleshoot workflow

* Continue troubleshooting workflow

* Fix Pifile syntax error

* Continue troubleshooting cowsay

* Run pishrink with sudo
  • Loading branch information
ethanjli authored May 27, 2024
1 parent 561b612 commit 742854c
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 10 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/test-pishrink.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: build-os
on:
pull_request:
branches:
- main
paths-ignore:
- '**/README.md'
push:
branches:
- main
paths-ignore:
- '**/README.md'
merge_group:
workflow_dispatch:

jobs:
build:
name: Build image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Make a Pifile for Pimod
uses: 1arp/create-a-file-action@0.4.5
with:
file: cowsay.Pifile
content: |
FROM https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz
TO cowsay-image.img
PUMP 8G
# Install and test out cowsay:
RUN apt-get update
RUN apt-get install -y cowsay
RUN /usr/games/cowsay "I'm running in a chroot!"
- name: Build the image
uses: Nature40/pimod@master
with:
pifile: cowsay.Pifile

- name: Shrink the image
uses: ./
with:
image: cowsay-image.img
compress: gzip
compress-parallel: true

- name: Upload image to Job Artifacts
uses: actions/upload-artifact@v4
with:
name: cowsay-image
path: cowsay-image.img.gz
if-no-files-found: error
retention-days: 0
compression-level: 0
overwrite: true
66 changes: 57 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ GitHub action to run [PiShrink](https://github.com/Drewsif/PiShrink) on a Raspbe

## Basic Usage Examples

Note: in the below example sequences of GitHub Actions job steps, the URL of the downloaded image
doesn't actually exist! Normally, you would generate an image file by some other method, e.g.
downloading a base image, expanding it, and modifying its filesystem (e.g. with
[Pimod](https://github.com/Nature40/pimod), as in [a below example](#pimod-usage-example)).

### Shrink with gzip

```
- name: Download an example image
# Note: this URL doesn't actually exist! Normally, you would generate an image file by some other
# method, e.g. downloading a base image, expanding it, and modifying its filesystem.
run: wget http://some-website.com/large-rpi-sd-card-image.img
- name: Shrink image
Expand All @@ -32,8 +35,6 @@ GitHub action to run [PiShrink](https://github.com/Drewsif/PiShrink) on a Raspbe

```
- name: Download an example image
# Note: this URL doesn't actually exist! Normally, you would generate an image file by some other
# method, e.g. downloading a base image, expanding it, and modifying its filesystem.
run: wget http://some-website.com/large-rpi-sd-card-image.img
- name: Shrink image
Expand All @@ -56,8 +57,6 @@ GitHub action to run [PiShrink](https://github.com/Drewsif/PiShrink) on a Raspbe

```
- name: Download an example image
# Note: this URL doesn't actually exist! Normally, you would generate an image file by some other
# method, e.g. downloading a base image, expanding it, and modifying its filesystem.
run: wget http://some-website.com/large-rpi-sd-card-image.img
- name: Shrink image
Expand All @@ -82,8 +81,6 @@ GitHub action to run [PiShrink](https://github.com/Drewsif/PiShrink) on a Raspbe

```
- name: Download an example image
# Note: this URL doesn't actually exist! Normally, you would generate an image file by some other
# method, e.g. downloading a base image, expanding it, and modifying its filesystem.
run: wget http://some-website.com/large-rpi-sd-card-image.img
- name: Shrink image
Expand All @@ -104,7 +101,58 @@ GitHub action to run [PiShrink](https://github.com/Drewsif/PiShrink) on a Raspbe
overwrite: true
```

### Usage Options
## Pimod Usage Example

This example job uses Pimod to generate a custom image, and then shrinks it before uploading as an
artifact on the GitHub Actions job:

```
jobs:
build:
name: Build image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Make a Pifile for Pimod
uses: 1arp/create-a-file-action@0.4.5
with:
file: cowsay.Pifile
content: |
FROM https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz
TO cowsay-image.img
PUMP 8G
# Install and test out cowsay:
RUN apt-get update
RUN apt-get install -y cowsay
RUN /usr/games/cowsay "I'm running in a chroot!"
- name: Build the image
uses: Nature40/pimod@master
with:
pifile: cowsay.Pifile
- name: Shrink the image
uses: ethanjli/pishrink-action@v0.1.0
with:
image: cowsay-image.img
compress: gzip
compress-parallel: true
- name: Upload image to Job Artifacts
uses: actions/upload-artifact@v4
with:
name: cowsay-image
path: cowsay-image.img.gz
if-no-files-found: error
retention-days: 0
compression-level: 0
overwrite: true
```

## Usage Options

Inputs:

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ runs:
fi
echo "Running pishrink.sh $flags ${{ inputs.image }} $destination..."
${{ github.action_path }}/pishrink.sh $flags ${{ inputs.image }} $destination
sudo ${{ github.action_path }}/pishrink.sh $flags ${{ inputs.image }} $destination

0 comments on commit 742854c

Please sign in to comment.