name: Test and publish container images on: push: branches: - main pull_request: permissions: contents: read packages: none env: REGISTRY: gitea.incoso.eu REGISTRY_OWNER: kevin_janssen jobs: test: runs-on: ubuntu-latest container: image: node:22-bookworm steps: - name: Check out source uses: actions/checkout@v4 - name: Install test dependencies run: | apt-get update apt-get install --yes --no-install-recommends jq python3 python3-pip util-linux rm -rf /var/lib/apt/lists/* python3 -m pip install \ --disable-pip-version-check \ --target .tools/python \ "osmium==4.3.1" - name: Install Node dependencies run: npm ci - name: Run type checks and tests run: | npm run typecheck npm test publish: if: ${{ gitea.event_name == 'push' }} needs: - test runs-on: ubuntu-latest steps: - name: Check out source uses: actions/checkout@v4 - name: Log in to the Gitea Container Registry env: REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} run: | test -n "$REGISTRY_USERNAME" test -n "$REGISTRY_TOKEN" printf '%s\n' "$REGISTRY_TOKEN" | docker login "$REGISTRY" --username "$REGISTRY_USERNAME" --password-stdin - name: Build images for the triggering commit env: REVISION: ${{ gitea.sha }} run: | test "$(printf '%s' "$REVISION" | wc -c)" -eq 40 docker build \ --label "org.opencontainers.image.revision=$REVISION" \ --label "org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}" \ --tag "$REGISTRY/$REGISTRY_OWNER/watermaps:$REVISION" \ . docker build \ --file deploy/route-data.Dockerfile \ --label "org.opencontainers.image.revision=$REVISION" \ --label "org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}" \ --tag "$REGISTRY/$REGISTRY_OWNER/watermaps-route-data:$REVISION" \ . - name: Push immutable commit images env: REVISION: ${{ gitea.sha }} run: | docker push "$REGISTRY/$REGISTRY_OWNER/watermaps:$REVISION" docker push "$REGISTRY/$REGISTRY_OWNER/watermaps-route-data:$REVISION" - name: Log out from the registry if: always() run: docker logout "$REGISTRY" || true