From c1da26d97335d0639a2acc6e7ba70304e86dea00 Mon Sep 17 00:00:00 2001 From: Mateusz Pstrucha Date: Sun, 4 Oct 2026 16:12:10 +0200 Subject: [PATCH] ci: release on tags and deploy to www.mtps.pl Mirror iledopapiezowej/frontend: CI on master and PRs, versioned release assets on v* tags, then deploy through ygg/actions/deploy. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/ci.yml | 39 ++++++++++++++++++++ .gitea/workflows/release.yml | 69 ++++++++++++++++++++++++++++++------ deploy/static.yml | 36 +++++++++++++++++++ package.json | 6 ++-- 4 files changed, 137 insertions(+), 13 deletions(-) create mode 100644 .gitea/workflows/ci.yml create mode 100644 deploy/static.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..6006a38 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + +# Superseding pushes shouldn't each wait for a full build on the shared +# runner. Releases deliberately aren't covered — cancelling a publish +# halfway is worse than running it twice. +concurrency: + group: ${{ gitea.workflow }}-${{ gitea.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: rocky-10 + steps: + - name: Check out source + uses: actions/checkout@v4 + + # Version comes from the packageManager field in package.json. + - name: Set up pnpm + uses: pnpm/action-setup@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 24 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Type check + run: pnpm check + + - name: Build + run: pnpm build diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 57b9581..8bdf374 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -1,31 +1,54 @@ name: Release +# v1.2.3 -> production build, release, deploy/static.yml (www.mtps.pl) on: push: - branches: - - master + tags: ['v*'] jobs: release: runs-on: rocky-10 + outputs: + version: ${{ steps.meta.outputs.version }} steps: - name: Check out source uses: actions/checkout@v4 + - name: Derive version + id: meta + run: | + VERSION="${GITHUB_REF_NAME#v}" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "$VERSION" + + # Version comes from the packageManager field in package.json. + - name: Set up pnpm + uses: pnpm/action-setup@v4 + - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 24 + cache: pnpm - - name: Install dependencies and build - run: | - corepack enable - corepack prepare pnpm@11.0.0 --activate - pnpm install --frozen-lockfile - pnpm run build + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Type check + run: pnpm check + + - name: Build + run: pnpm build - name: Create release archive - run: tar -czf dist.tar.gz -C build . + env: + VERSION: ${{ steps.meta.outputs.version }} + run: | + NAME="${{ gitea.event.repository.name }}-${VERSION}.tgz" + # Archive the *contents* of build/ rather than build/ itself, so it + # untars straight into a web root. + tar -czf "$NAME" -C build . + sha256sum "$NAME" > "$NAME.sha256" - name: Create release uses: akkuman/gitea-release-action@v1 @@ -34,4 +57,28 @@ jobs: server_url: ${{ gitea.server_url }} tag_name: ${{ gitea.ref_name }} name: ${{ gitea.ref_name }} - files: dist.tar.gz + files: |- + ${{ gitea.event.repository.name }}-*.tgz + ${{ gitea.event.repository.name }}-*.tgz.sha256 + + # static-server on kara downloads the release asset, so this runs after it + deploy: + needs: release + runs-on: rocky-10 + # never run two deploys at once + concurrency: + group: deploy-${{ gitea.repository }} + cancel-in-progress: false + steps: + - name: Check out source + uses: actions/checkout@v4 + + - name: Deploy + uses: https://git.app.ygg/ygg/actions/deploy@v2 + with: + type: static + dist-path: deploy/static.yml + extra-vars: | + static_release=${{ needs.release.outputs.version }} + ssh-key: ${{ secrets.DEPLOY_SSH_KEY }} + known-hosts: ${{ vars.DEPLOY_KNOWN_HOSTS }} diff --git a/deploy/static.yml b/deploy/static.yml new file mode 100644 index 0000000..2db7c98 --- /dev/null +++ b/deploy/static.yml @@ -0,0 +1,36 @@ +--- +# Static site: https://git.app.ygg/mtps/homepage +# +# Deployed by .gitea/workflows/release.yml through ygg/actions/deploy +# (deploy/static playbook on kara). +# +# static_release is passed by the release workflow (-e static_release=1.2.3). +# For a manual run pass it the same way, there's deliberately no default here. +# Release assets are versioned (homepage-.tgz), and static-server only +# auto-detects *.tar.gz, so the asset is named explicitly. + +static_stack_name: homepage + +domain: www.mtps.pl +# /etc/nginx/certs/.conf on the nginx host +cert: mtps.pl + +# static_service replaces the role default as a whole, so every key is required +static_service: + name: static + image: "{{ gitea_host }}/ygg/static-server:latest" + environment: + GITEA_REPOSITORY_URL: "https://{{ gitea_host }}/mtps/homepage" + GITEA_RELEASE: "v{{ static_release }}" + GITEA_ASSET_NAME: "homepage-{{ static_release }}.tgz" + SSL_CERT_FILE: /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem + volumes: + - /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem:/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem:ro + ports: + - target: 8080 + published: 11903 + protocol: tcp + mode: ingress + replicas: 3 + restart_policy: + condition: on-failure diff --git a/package.json b/package.json index efe2898..2330d86 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "homepage", "version": "1.0.3", "private": true, + "packageManager": "pnpm@11.28.2", "engines": { "node": ">=18.18.0", "pnpm": ">=11.0.0" @@ -26,7 +27,8 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "check": "tsc --noEmit" }, "eslintConfig": { "extends": [ @@ -46,4 +48,4 @@ "last 1 safari version" ] } -} \ No newline at end of file +}