Add Incus publish job
This commit is contained in:
parent
f98ca93619
commit
1bca4ee0f5
1 changed files with 32 additions and 0 deletions
32
cfg/jobs/incus_publish.run
Normal file
32
cfg/jobs/incus_publish.run
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/env bash
|
||||||
|
set -euxo pipefail
|
||||||
|
|
||||||
|
# Clean
|
||||||
|
incus exec "$CNAME" -- \
|
||||||
|
rm -rf \
|
||||||
|
/etc/machine-id \
|
||||||
|
/var/cache/apt \
|
||||||
|
/var/log/journal
|
||||||
|
|
||||||
|
# Publish
|
||||||
|
incus stop "$CNAME"
|
||||||
|
incus config metadata show "$CNAME" > "$ARCHIVE"/metadata.yaml
|
||||||
|
# Get the current Unix timestamp
|
||||||
|
current_timestamp=$(date +%s)
|
||||||
|
# Calculate expiry date as current timestamp + 1 week (604800 seconds)
|
||||||
|
expiry_date=$((current_timestamp + 604800))
|
||||||
|
# Update metadata values
|
||||||
|
sed -i \
|
||||||
|
-e "s/creation_date: .*/creation_date: $current_timestamp/" \
|
||||||
|
-e "s/expiry_date: .*/expiry_date: $expiry_date/" \
|
||||||
|
-e "s#description: .*#description: $UPSTREAM_NAME v$UPSTREAM_VER on $IMAGE release $SERIAL#" \
|
||||||
|
-e "s/name: .*/name: $CNAME/" \
|
||||||
|
-e "s/serial: .*/serial: $SERIAL/" \
|
||||||
|
"$ARCHIVE"/metadata.yaml
|
||||||
|
|
||||||
|
incus config metadata edit "$CNAME" < "$ARCHIVE"/metadata.yaml
|
||||||
|
incus publish "$CNAME" \
|
||||||
|
--alias "$ALIAS" \
|
||||||
|
--public \
|
||||||
|
--quiet
|
||||||
|
incus rm "$CNAME"
|
Loading…
Add table
Reference in a new issue