55 lines
1.5 KiB
YAML
55 lines
1.5 KiB
YAML
name: Build Docker Image
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DISCORD_TOKEN: "0"
|
|
OPENAI_TOKEN: "0"
|
|
steps:
|
|
# GitHub Container Registry
|
|
- uses: docker/login-action@v3
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
registry: ghcr.io
|
|
username: thelovinator1
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# Download the latest commit from the master branch
|
|
- uses: actions/checkout@v5
|
|
|
|
# Install the latest version of ruff
|
|
- uses: astral-sh/ruff-action@v3
|
|
with:
|
|
version: "latest"
|
|
|
|
# Lint the Python code using ruff
|
|
- run: ruff check --exit-non-zero-on-fix --verbose
|
|
|
|
# Check if the Python code needs formatting
|
|
- run: ruff format --check --verbose
|
|
|
|
# Lint Dockerfile
|
|
- run: docker build --check .
|
|
|
|
# Extract metadata (tags, labels) from Git reference and GitHub events for Docker
|
|
- id: meta
|
|
uses: docker/metadata-action@v5
|
|
if: github.ref == 'refs/heads/master'
|
|
with:
|
|
images: ghcr.io/thelovinator1/anewdawn
|
|
tags: type=raw,value=latest
|
|
|
|
# Build and push the Docker image
|
|
- uses: docker/build-push-action@v6
|
|
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
|
|
with:
|
|
context: .
|
|
push: true
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|