-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.yml
100 lines (97 loc) · 3.46 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: RPi Image Modifier
description: Raspberry Pi OS Image Modifier
inputs:
base-image-url:
description: 'Base Raspberry Pi OS image URL (required)'
required: true
script-path:
description: 'Path of script to run to modify image (one of script-path or run is required)'
required: false
default: ''
run:
description: 'Script contents run to modify image (one of script-path or run is required)'
required: false
default: ''
env-vars:
description: 'Comma-separated environment variables to pass to the script, example: ONE,TWO,THREE'
required: false
default: ''
image-path:
description: 'What to name the modified image'
required: false
default: 'rpi-os-modified.img'
mount-repository:
description: 'Temporary mount repository at /mounted-github-repo/ for copying files'
required: false
default: 'true'
compress-with-xz:
description: 'Compress final image with xz (image-path output will have an .xz extension added)'
required: false
default: 'false'
extra-xz-args:
description: 'Extra arguments to pass to the xz command'
required: false
default: ''
shrink:
description: 'Shrink final image using PiShrink (https://github.com/Drewsif/PiShrink)'
required: false
default: 'true'
shell:
description: 'Shell in container to execute script'
required: false
default: '/bin/bash'
cache:
description: 'Cache image file located at base-image-url'
required: false
default: 'false'
image-maxsize:
description: 'That maximum size of the modified image (needs to fit on disk)'
required: false
default: '12G'
outputs:
image-path:
description: 'Filename of image, will be same as image-path unless compress-with-xz is set in which case it will have a .xz extension'
value: ${{ steps.modify-image.outputs.image-path }}
image-size:
description: 'Size of image, as it was before xz compression was optionally applied'
value: ${{ steps.modify-image.outputs.image-size }}
image-sha256sum:
description: 'SHA256 sum of image file after xz compression is optionally applied'
value: ${{ steps.modify-image.outputs.image-sha256sum }}
runs:
using: "composite"
steps:
-
name: Set cache key
id: cache-key
if: inputs.cache == 'true'
shell: bash
env:
ARG_BASE_IMAGE_URL: ${{ inputs.base-image-url }}
run: |
echo "key=rpi-img-mod-2::$(basename "${ARG_BASE_IMAGE_URL}")" >> "${GITHUB_OUTPUT}"
-
name: Use cache
if: inputs.cache == 'true'
uses: actions/cache@v3
with:
key: ${{ steps.cache-key.outputs.key }}
path: /tmp/rpi-cached.img
-
name: Modify Raspberry Pi OS image
shell: bash
id: modify-image
env:
__ARG_BASE_IMAGE_URL: ${{ inputs.base-image-url }}
__ARG_SCRIPT_PATH: ${{ inputs.script-path }}
__ARG_RUN: ${{ inputs.run }}
__ARG_ENV_VARS: ${{ inputs.env-vars}}
__ARG_IMAGE_PATH: ${{ inputs.image-path }}
__ARG_MOUNT_REPOSITORY: ${{ inputs.mount-repository == 'true' && '1' || '' }}
__ARG_COMPRESS_WITH_XZ: ${{ inputs.compress-with-xz == 'true' && '1' || '' }}
__ARG_EXTRA_XZ_ARGS: ${{ inputs.extra-xz-args }}
__ARG_SHRINK: ${{ inputs.shrink == 'true' && '1' || '' }}
__ARG_SHELL: ${{ inputs.shell }}
__ARG_CACHE: ${{ inputs.cache == 'true' && '1' || '' }}
__ARG_IMAGE_MAXSIZE: ${{ inputs.image-maxsize }}
run: "${GITHUB_ACTION_PATH}/action.sh"