ui/.forgejo/workflows/deploy.yaml
Alois be8eb83e02
Some checks failed
/ deploy-and-package (push) Failing after 44s
(fix): workflows
(qol): dumb version
2026-07-26 15:24:18 +02:00

69 lines
2.1 KiB
YAML

on:
push:
branches:
- main
env:
NIX_CONFIG: experimental-features = nix-command flakes
jobs:
deploy-and-package:
runs-on: nixos
steps:
- name: Install deps
run: |
nix profile add nixpkgs#nodejs_24 nixpkgs#pnpm nixpkgs#rsync nixpkgs#jq nixpkgs#gnused
pnpm install --frozen-lockfile
- name: Check out repo
uses: https://data.forgejo.org/actions/checkout@v4
- name: Build and package
run: |
pnpm pack
pnpm --filter @methanium/ui-showcase build
- name: Deploy
run: rsync -a --delete apps/showcase/dist/ /var/lib/www/methanium-ui/
- name: Create release and upload package
env:
TOKEN: ${{ forgejo.token }}
API: ${{ forgejo.api_url }}
REPO: ${{ forgejo.repository }}
SHA: ${{ forgejo.sha }}
run: |
set -eu
TAG="$(node -p "require('./package.json').version")"
PACKAGE="methanium-ui.tgz"
test -f "$PACKAGE"
HTTP_STATUS=$(curl -s -w "%{http_code}" -o release_out.json -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/tags/$TAG")
if [ "$HTTP_STATUS" = "200" ]; then
echo "Release $TAG already exists."
RELEASE_ID="$(jq -r .id release_out.json)"
else
echo "Creating release for $TAG"
RELEASE_JSON="$(curl -f -sS -X POST "$API/repos/$REPO/releases" \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n \
--arg tag "$TAG" \
--arg target "$SHA" \
'{
tag_name: $tag,
name: $tag,
body: "This is an automated release.",
target_commitish: $target,
draft: false,
prerelease: false
}')")"
RELEASE_ID="$(echo "$RELEASE_JSON" | jq -r .id)"
fi
curl -fsS -X POST "$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$PACKAGE" \
-H "Authorization: token $TOKEN" \
-F "attachment=@$PACKAGE"