diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..660e61f --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,113 @@ +--- +name: Test code; build Docker image; push to Docker Hub, GitHub Container Registry and Gitea. +on: + push: + branches: + - master + pull_request: + workflow_dispatch: + schedule: + - cron: "@daily" + +env: + SERVE_DOMAIN: https://localhost/ + WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} + UPLOAD_FOLDER: ./Uploads + +jobs: + test: + runs-on: ubuntu-latest + steps: + # GitHub Container Registry + - uses: https://github.com/docker/login-action@v3 + if: github.event_name != 'pull_request' + with: + registry: ghcr.io + username: thelovinator1 + password: ${{ secrets.PACKAGES_WRITE_GITHUB_TOKEN }} + + # Gitea Container Registry + - uses: https://github.com/docker/login-action@v3 + if: github.event_name != 'pull_request' + with: + registry: git.lovinator.space + username: thelovinator + password: ${{ secrets.PACKAGES_WRITE_GITEA_TOKEN }} + + # Docker Hub Registry + - uses: https://github.com/docker/login-action@v3 + if: github.event_name != 'pull_request' + with: + registry: docker.io + username: thelovinator + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Download the latest commit from the master branch + - uses: https://github.com/actions/checkout@v4 + + # Set up QEMU + - id: qemu + uses: https://github.com/docker/setup-qemu-action@v3 + with: + image: tonistiigi/binfmt:master + platforms: linux/amd64,linux/arm64 + cache-image: false + + # Set up Buildx so we can build multi-arch images + - uses: https://github.com/docker/setup-buildx-action@v3 + + + # Install ffmpeg + - name: Install ffmpeg + run: | + sudo apt-get update + sudo apt-get install -y ffmpeg + + # Set up uv for Python dependency management + - uses: astral-sh/setup-uv@v5 + with: + version: "latest" + + # Install dependencies + - run: uv sync --all-extras --all-groups + + # Run tests + - run: uv run pytest + + # Install the latest version of ruff + - uses: https://github.com/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: https://github.com/docker/metadata-action@v5 + env: + DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index + with: + images: | + ghcr.io/thelovinator1/discord-embed + thelovinator/discord-nice-embed-maker-for-my-yoy + git.lovinator.space/thelovinator/anewdawn + tags: | + type=raw,value=latest,enable=${{ gitea.ref == format('refs/heads/{0}', 'master') }} + type=raw,value=master,enable=${{ gitea.ref == format('refs/heads/{0}', 'master') }} + + # Build and push the Docker image + - uses: https://github.com/docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ gitea.event_name != 'pull_request' }} + labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} + annotations: ${{ steps.meta.outputs.annotations }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 7118997..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,80 +0,0 @@ ---- -name: Test code, build Docker image, and push to Docker Hub and GitHub Container Registry. -on: - push: - pull_request: - workflow_dispatch: - schedule: - - cron: "0 6 * * *" - -env: - SERVE_DOMAIN: https://localhost/ - WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} - UPLOAD_FOLDER: ./Uploads - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: FedericoCarboni/setup-ffmpeg@v3 - id: setup-ffmpeg - - uses: actions/setup-python@v5 - with: - python-version: 3.13 - - uses: astral-sh/setup-uv@v5 - with: - version: "latest" - - run: uv sync --all-extras --all-groups - - run: uv run pytest - ruff: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: astral-sh/ruff-action@v3 - with: - version: "latest" - - run: ruff check --exit-non-zero-on-fix --verbose - - run: ruff format --check --verbose - build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - if: github.event_name != 'pull_request' - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - needs: [test, ruff] - steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v3 - with: - platforms: all - - uses: docker/setup-buildx-action@v3 - - name: Login to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Login to GitHub Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64, linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: | - ghcr.io/thelovinator1/discord-embed:latest - ghcr.io/thelovinator1/discord-embed:master - thelovinator/discord-nice-embed-maker-for-my-yoy:latest - thelovinator/discord-nice-embed-maker-for-my-yoy:master