# Code quality checks on master and pull requests. The server and client jobs # only run when their directory (or shared root files) changed. On a release # tag push (vX.Y.Z), runs both jobs unconditionally and then builds the Docker # image and pushes it to this Gitea instance's container registry, tagged with # the version and `latest`. The tag must match the root package.json version. # # Needs a repository (or owner) secret REGISTRY_TOKEN: a Gitea access token # with package write access for the repository owner. The registry host is # set explicitly below rather than taken from the server URL, which is the # address the runner was registered with and may be internal-only. name: CI on: push: branches: [master] tags: ['v[0-9]+.[0-9]+.[0-9]+'] pull_request: env: REGISTRY: git.hq.ars9.space jobs: # Not needed on tag pushes: server and client always run there changes: if: ${{ !startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest outputs: server: ${{ steps.filter.outputs.server }} client: ${{ steps.filter.outputs.client }} steps: - uses: actions/checkout@v4 - uses: dorny/paths-filter@v3 id: filter with: filters: | server: - 'server/**' - 'package.json' - 'package-lock.json' - '.gitea/workflows/ci.yml' client: - 'client/**' - 'package.json' - 'package-lock.json' - '.gitea/workflows/ci.yml' server: needs: changes # changes is skipped on tag pushes, hence !cancelled() if: | !cancelled() && (startsWith(github.ref, 'refs/tags/') || needs.changes.outputs.server == 'true') runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 cache: npm - run: npm ci -w server - name: Lint run: npm run -w server lint -- --max-warnings=0 - name: Type-check run: npx tsc --noEmit -p server/tsconfig.json - name: Test run: npm test -w server - name: Build run: npm run -w server build client: needs: changes # changes is skipped on tag pushes, hence !cancelled() if: | !cancelled() && (startsWith(github.ref, 'refs/tags/') || needs.changes.outputs.client == 'true') runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 cache: npm - run: npm ci -w client - name: Lint run: npm run -w client lint -- --max-warnings=0 - name: Build run: npm run -w client build - name: Install headless Chromium for Storybook tests run: npx playwright install --with-deps --only-shell chromium - name: Storybook tests run: npm run -w client test:storybook image: needs: [server, client] if: ${{ !failure() && !cancelled() && startsWith(github.ref, 'refs/tags/') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Check the tag matches package.json run: | version=$(node -p "require('./package.json').version") if [ "${GITHUB_REF_NAME}" != "v${version}" ]; then echo "tag ${GITHUB_REF_NAME} does not match package.json version ${version}" exit 1 fi echo "VERSION=${version}" >> "$GITHUB_ENV" - name: Log in to the registry env: REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} OWNER: ${{ github.repository_owner }} run: | echo "IMAGE=${REGISTRY}/$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV" echo "$REGISTRY_TOKEN" | docker login "$REGISTRY" -u "$OWNER" --password-stdin - name: Build run: docker build --build-arg VERSION="${VERSION}" -t "${IMAGE}:${VERSION}" -t "${IMAGE}:latest" . - name: Push run: | docker push "${IMAGE}:${VERSION}" docker push "${IMAGE}:latest"