-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (70 loc) · 2.36 KB
/
factory-run.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
name: Factory Build (single)
on:
workflow_dispatch:
inputs:
factoryTag:
description: The factory tag to use when building
type: string
required: true
configName:
description: Config Name
type: string
required: true
configLiteralb64gz:
description: base64+gzip-encoded config
type: string
required: false
configURL:
description: URL to download config from
type: string
required: false
configPath:
description: Path in this repo of config to use
type: string
required: false
uploadURL:
description: Upload result to
type: string
required: false
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build klipper firmware
env:
CONFIG_LITERAL: "${{inputs.configLiteralb64gz}}"
CONFIG_URL: "${{inputs.configURL}}"
CONFIG_PATH: "${{inputs.configPath}}"
CONFIG_NAME: "${{inputs.configName}}"
FACTORY_TAG: "${{inputs.factoryTag}}"
run: |
tmp_dir="$(mktemp -d -t klipperfactory.XXXXXXXXXX)"
if [[ $CONFIG_LITERAL ]]; then
base64 -d <<<"$CONFIG_LITERAL" | gunzip > "$tmp_dir/$CONFIG_NAME.config"
elif [[ $CONFIG_URL ]]; then
curl --fail -L "$CONFIG_URL" > "$tmp_dir/$CONFIG_NAME.config"
elif [[ $CONFIG_PATH ]]; then
cp "$CONFIG_PATH" "$tmp_dir/$CONFIG_NAME.config"
else
echo >&2 "Unable to locate config file"
exit 2
fi
mkdir "$tmp_dir/out"
setfacl -Rm u:1000:rX "$tmp_dir"
setfacl -m u:1000:rwX "$tmp_dir/out"
docker run --rm -v "$tmp_dir":/mnt:z "ghcr.io/laikulo/klipper-firmware/factory:$FACTORY_TAG" -c "/mnt/$CONFIG_NAME.config" -o /mnt/out
cp -r "$tmp_dir/out" "./factory-output"
- name: Upload to URL
if: "${{inputs.uploadURL}}"
run: |
set +x
output_files=( "factory-output/"*".tgz" )
curl -XPOST '${{inputs.uploadURL}}' -H 'Content-Type: application/gzip' --data-binary "@${output_files[0]}"
- name: Upload to Github
uses: actions/[email protected]
with:
path: factory-output/*.tgz