Files
liqa/.gitea/workflows/ci.yml
T
Andrii Arsenin ed22697808
CI / server (push) Failing after 3m50s
CI / client (push) Successful in 1m40s
CI / version (push) Successful in 6s
CI / image (push) Skipped
ci: set the image registry explicitly
- use REGISTRY (git.hq.ars9.space) for login and image tags instead of
  deriving it from the server url, which is the runner's registration
  address and may be internal-only
- document how jobs reach gitea when the runner uses an internal address
2026-10-01 11:11:39 +03:00

107 lines
3.4 KiB
YAML

# 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 -t "${IMAGE}:${VERSION}" -t "${IMAGE}:latest" .
- name: Push
run: |
docker push "${IMAGE}:${VERSION}"
docker push "${IMAGE}:latest"