From 35183f267fb6ba153b8835a97621804b46d4b67d Mon Sep 17 00:00:00 2001 From: Max Richter Date: Sat, 11 Oct 2025 12:36:33 +0200 Subject: [PATCH] feat: trying to add gitea workflow --- .gitea/workflows/build.yml | 78 ++++++++++++++++++++++++++++++++++++++ mise.toml | 1 + 2 files changed, 79 insertions(+) create mode 100644 .gitea/workflows/build.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..44538ad --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,78 @@ +name: Build and Push Server + +# This workflow runs on every push to the main branch. +on: + push: + branches: + - main + +jobs: + build-and-push: + # The job runs on a standard Ubuntu runner. + runs-on: ubuntu-latest + + steps: + # Step 1: Check out the repository code. + - name: Checkout repository + uses: actions/checkout@v4 + + # Step 2: Set up the Node.js environment for building the SvelteKit playground. + - name: Setup Mise + uses: jdx/mise-action@v3 + + # Step 3: Set up pnpm, which is used for dependency management in the playground. + - name: Set up pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + + # Step 4: Install the playground's dependencies. + - name: Install playground dependencies + working-directory: ./playground + run: pnpm install --frozen-lockfile + + - name: Build marka wasm + working-directory: ./playground + run: ./wasm/build.sh + + # Step 5: Build the SvelteKit playground to generate static assets. + - name: Build playground + working-directory: ./playground + run: pnpm build + + # Step 6: The Dockerfile expects the built playground assets in './server/playground'. + # This step moves the build output from './playground/build' to the correct location. + - name: Move playground build to server context + run: | + echo "Moving playground build output..." + rm -rf ./server/playground + mv ./playground/build ./server/playground + echo "Move complete." + + # Step 7: Log in to the Gitea container registry. + # You need to create a repository secret named GITEA_TOKEN with an access token. + - name: Login to Gitea Registry + uses: docker/login-action@v3 + with: + registry: ${{ gitea.instance }} + username: ${{ gitea.actor }} + password: ${{ secrets.GITEA_TOKEN }} + + # Step 8: Get the short commit SHA to use as an image tag. + - name: Get short commit hash + id: commit + run: echo "sha_short=$(echo ${{ gitea.commit_sha }} | cut -c1-7)" >> $GITEA_OUTPUT + + # Step 9: Build the Docker image and push it to the Gitea registry. + # The image is tagged with 'latest' and the short commit SHA. + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./server/Dockerfile + push: true + tags: | + ${{ gitea.instance }}/${{ gitea.repository_owner }}/${{ gitea.repository_name }}:latest + ${{ gitea.instance }}/${{ gitea.repository_owner }}/${{ gitea.repository_name }}:${{ steps.commit.outputs.sha_short }} + build-args: | + GIT_COMMIT=${{ gitea.commit_sha }} diff --git a/mise.toml b/mise.toml index d076463..ffca9b0 100644 --- a/mise.toml +++ b/mise.toml @@ -1,2 +1,3 @@ [tools] go = "1.24.7" +node = "latest"