-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yml
85 lines (78 loc) · 2.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
name: "Create rpi-imager.json snippet"
description: "Generates an rpi-imager.json snippet based on given checksums, sizes and metadata"
inputs:
name:
description: "The name of the distribution"
required: true
description:
description: "The description of the distribution"
required: true
icon:
description: "The icon of the distribution"
required: true
url:
description: "The download URL for the image zip"
required: true
output:
description: "The path to the rpi-imager.json file"
required: true
image_sha256:
description: "The sha256 checksum of the image"
required: true
image_size:
description: "The size of the image"
required: true
zip_sha256:
description: "The sha256 checksum of the zip"
required: true
zip_size:
description: "The size of the zip"
required: true
devices:
description: "Which Pis this image supports, comma separated, will be left out if not provided"
init_format:
description: "The init format of the image, defaults to systemd"
runs:
using: "composite"
steps:
- name: "🆕 Create rpi-imager.json snippet"
run: |
IMAGE_SHA256="${{ inputs.image_sha256 }}"
IMAGE_SIZE=${{ inputs.image_size }}
ZIP_SHA256="${{ inputs.zip_sha256 }}"
ZIP_SIZE=${{ inputs.zip_size }}
OUTPUT="${{ inputs.output }}"
NAME="${{ inputs.name }}"
DESCRIPTION="${{ inputs.description }}"
ICON="${{ inputs.icon }}"
URL="${{ inputs.url }}"
DATE=`date '+%Y-%m-%d'`
INIT_FORMAT="${{ inputs.init_format }}"
DEVICES_RAW="${{ inputs.devices }}"
if [ -z "$INIT_FORMAT" ]; then
INIT_FORMAT="systemd"
fi
IFS=', ' read -r -a DEVICES_ARR <<< "$DEVICES_RAW"
DEVICES=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${DEVICES_ARR[@]}")
cat > "$OUTPUT" <<EOF
{
"name": "$NAME",
"description": "$DESCRIPTION",
"url": "$URL",
"icon": "$ICON",
"release_date": "$DATE",
"extract_size": $IMAGE_SIZE,
"extract_sha256": "$IMAGE_SHA256",
"image_download_size": $ZIP_SIZE,
"image_download_sha256": "$ZIP_SHA256",
EOF
if [ -n "$DEVICES_RAW" ]; then
cat >> "$OUTPUT" <<EOF
"devices": $DEVICES,
EOF
fi
cat >> "$OUTPUT" <<EOF
"init_format": "$INIT_FORMAT"
}
EOF
shell: bash