# Code quality checks on master and pull requests. On a push to master that # changes the version in the root package.json, also builds the Docker image # and pushes it to this Gitea instance's container registry, tagged with that # version and `latest`. # # 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] pull_request: env: REGISTRY: git.hq.ars9.space jobs: server: 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: 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 # Compares the root package.json version with the one before the push version: if: github.event_name == 'push' runs-on: ubuntu-latest outputs: version: ${{ steps.check.outputs.version }} changed: ${{ steps.check.outputs.changed }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - id: check env: BEFORE: ${{ github.event.before }} run: | version=$(node -p "require('./package.json').version") previous="" if git cat-file -e "${BEFORE}^{commit}" 2>/dev/null; then previous=$(git show "${BEFORE}:package.json" | node -p "JSON.parse(require('fs').readFileSync(0, 'utf8')).version") fi echo "version: ${previous:-none} -> ${version}" echo "version=${version}" >> "$GITHUB_OUTPUT" if [ "$version" != "$previous" ]; then echo "changed=true" >> "$GITHUB_OUTPUT" else echo "changed=false" >> "$GITHUB_OUTPUT" fi image: needs: [server, client, version] if: needs.version.outputs.changed == 'true' runs-on: ubuntu-latest env: VERSION: ${{ needs.version.outputs.version }} steps: - uses: actions/checkout@v4 - 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"