Improved README and ui-asset workflow
All checks were successful
checks-impure / test (pull_request) Successful in 25s
checks / test (pull_request) Successful in 1m24s

This commit is contained in:
2023-10-30 16:51:39 +01:00
parent 5273eee89f
commit 84c5b0477e
4 changed files with 42 additions and 17 deletions

View File

@@ -3,8 +3,17 @@ set -xeuo pipefail
# GITEA_TOKEN
if [[ -z "${GITEA_TOKEN:-}" ]]; then
echo "GITEA_TOKEN is not set"
echo "Go to https://gitea.gchq.icu/user/settings/applications and generate a token"
echo "GITEA_TOKEN is not set. Check if the secret BOT_ACCESS_TOKEN is set in the repository settings."
exit 1
fi
if [[ -z "${BOT_NAME:-}" ]]; then
echo "Env var BOT_NAME is not set. Use the name of the bot user here."
exit 1
fi
if [[ -z "${GITHUB_SERVER_URL:-}" ]]; then
echo "Env var GITHUB_SERVER_URL is not set. Please use the Gitea base URL here."
exit 1
fi
@@ -22,11 +31,12 @@ nix build '.#ui' --out-link "$tmpdir/result"
tar --transform 's,^\.,assets,' -czvf "$tmpdir/assets.tar.gz" -C "$tmpdir"/result/lib/node_modules/*/out .
NAR_HASH=$(nix-prefetch-url --unpack file://<(cat "$tmpdir/assets.tar.gz"))
owner=ui-asset-bot
owner=$BOT_NAME
package_name=ui
package_version=$NAR_HASH
baseurl=$GITHUB_SERVER_URL
url="https://gitea.gchq.icu/api/packages/$owner/generic/$package_name/$package_version/assets.tar.gz"
url="$baseurl/api/packages/$owner/generic/$package_name/$package_version/assets.tar.gz"
set +x
curl --upload-file "$tmpdir/assets.tar.gz" -X PUT "$url?token=$GITEA_TOKEN"
set -x