name: CI on: push: paths-ignore: - "*.md" pull_request: paths-ignore: - "*.md" workflow_dispatch: jobs: ci: runs-on: self-hosted env: DISCORD_TOKEN: "0" OPENAI_TOKEN: "0" DEEPSEEK_API_KEY: "0" steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 - name: Install dependencies run: uv sync --all-extras --dev -U - name: Lint the Python code using ruff run: ruff check --exit-non-zero-on-fix --verbose - name: Check formatting run: ruff format --check --verbose - name: Run tests run: uv run pytest build: needs: ci runs-on: self-hosted steps: - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 - id: tags name: Compute image tags run: | IMAGE="git.lovinator.space/thelovinator/anewdawn" if [ "${FORGEJO_REF}" = "refs/heads/master" ]; then echo "tags=${IMAGE}:latest,${IMAGE}:master" >> "$FORGEJO_OUTPUT" else SHORT_SHA="$(echo "$FORGEJO_SHA" | cut -c1-12)" echo "tags=${IMAGE}:sha-${SHORT_SHA}" >> "$FORGEJO_OUTPUT" fi - name: Login to Forgejo Container Registry run: echo "${{ secrets.PACKAGE_TOKEN }}" | docker login git.lovinator.space -u "${{ github.actor }}" --password-stdin # Build and (optionally) push the Docker image - name: Build and push Docker image env: TAGS: ${{ steps.tags.outputs.tags }} run: | IFS=',' read -r -a tag_array <<< "$TAGS" tag_args=() for tag in "${tag_array[@]}"; do tag_args+=( -t "$tag" ) done publish=0 if [ "${FORGEJO_REF}" = "refs/heads/master" ]; then publish=1 fi mode=(--load) if [ "${publish}" = "1" ]; then mode=(--push) fi docker buildx build \ --cache-from type=gha \ --build-arg "BUILD_SOURCE=https://git.lovinator.space/TheLovinator/ANewDawn" \ --build-arg "BUILD_REVISION=${FORGEJO_SHA}" \ --build-arg "BUILD_CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ "${mode[@]}" \ "${tag_args[@]}" \ .