name: build on: push: branches: [main] tags: ["v*"] pull_request: env: REGISTRY: git.necloud.us IMAGE: git.necloud.us/nate/audiobook-player jobs: check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Syntax check run: python3 -m py_compile server.py - name: Check the page script parses run: | python3 - <<'PY' import re open("/tmp/page.js", "w").write(re.search(r"", open("index.html").read(), re.S).group(1)) PY node --check /tmp/page.js image: needs: check if: github.event_name != 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Log in to the Gitea container registry run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$REGISTRY" -u "${{ secrets.REGISTRY_USER }}" --password-stdin - name: Build run: docker build --platform linux/amd64 -t "$IMAGE:${{ gitea.sha }}" -t "$IMAGE:latest" . - name: Smoke test (server refuses to start without accounts, but must import and print usage) run: docker run --rm "$IMAGE:latest" python server.py users - name: Push run: | docker push "$IMAGE:${{ gitea.sha }}" docker push "$IMAGE:latest" if [ "${{ gitea.ref_type }}" = "tag" ]; then docker tag "$IMAGE:latest" "$IMAGE:${{ gitea.ref_name }}" docker push "$IMAGE:${{ gitea.ref_name }}" fi