From b994d27b0cba0c30435537240d2a4c43892f0c0f Mon Sep 17 00:00:00 2001 From: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com> Date: Sun, 30 Mar 2025 20:38:01 +0200 Subject: [PATCH] dev: add pull request image build workflow (#5235) --- ...{partial-package.yml => build-package.yml} | 2 +- .github/workflows/e2e.yml | 7 ---- .github/workflows/nightly.yml | 17 ++++++--- .../{partial-builder.yml => publish.yml} | 7 ---- .github/workflows/pull-requests.yml | 38 ++++++++++++++++--- .github/workflows/release.yml | 19 +++++++--- .../{partial-backend.yml => test-backend.yml} | 0 ...partial-frontend.yml => test-frontend.yml} | 0 8 files changed, 58 insertions(+), 32 deletions(-) rename .github/workflows/{partial-package.yml => build-package.yml} (99%) rename .github/workflows/{partial-builder.yml => publish.yml} (90%) rename .github/workflows/{partial-backend.yml => test-backend.yml} (100%) rename .github/workflows/{partial-frontend.yml => test-frontend.yml} (100%) diff --git a/.github/workflows/partial-package.yml b/.github/workflows/build-package.yml similarity index 99% rename from .github/workflows/partial-package.yml rename to .github/workflows/build-package.yml index 1ee258562..bae0de02c 100644 --- a/.github/workflows/partial-package.yml +++ b/.github/workflows/build-package.yml @@ -1,4 +1,4 @@ -name: Package build +name: Build Package on: workflow_call: diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index df3e5b3a2..a13cc2d23 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -3,15 +3,8 @@ on: workflow_call: jobs: - build-package: - name: "Build Python package" - uses: ./.github/workflows/partial-package.yml - with: - tag: e2e - test: timeout-minutes: 60 - needs: build-package runs-on: ubuntu-latest defaults: run: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e2558c4bc..1e6ea0257 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -18,13 +18,19 @@ concurrency: jobs: backend-tests: name: "Backend Server Tests" - uses: ./.github/workflows/partial-backend.yml + uses: ./.github/workflows/test-backend.yml frontend-tests: name: "Frontend Tests" - uses: ./.github/workflows/partial-frontend.yml + uses: ./.github/workflows/test-frontend.yml - build-release: + build-package: + name: Build Package + uses: ./.github/workflows/build-package.yml + with: + tag: nightly + + publish: permissions: contents: read packages: write @@ -35,10 +41,11 @@ jobs: id-token: write name: Build Tagged Release if: github.repository == 'mealie-recipes/mealie' - uses: ./.github/workflows/partial-builder.yml + uses: ./.github/workflows/publish.yml needs: - frontend-tests - backend-tests + - build-package with: tag: nightly secrets: @@ -49,7 +56,7 @@ jobs: name: Notify Discord if: github.repository == 'mealie-recipes/mealie' needs: - - build-release + - publish runs-on: ubuntu-latest steps: - name: Discord notification diff --git a/.github/workflows/partial-builder.yml b/.github/workflows/publish.yml similarity index 90% rename from .github/workflows/partial-builder.yml rename to .github/workflows/publish.yml index 573325da1..d0fdee5a3 100644 --- a/.github/workflows/partial-builder.yml +++ b/.github/workflows/publish.yml @@ -16,14 +16,7 @@ on: required: true jobs: - build-package: - name: "Build Python package" - uses: ./.github/workflows/partial-package.yml - with: - tag: ${{ inputs.tag }} - publish: - needs: build-package runs-on: ubuntu-latest steps: - name: Checkout repository diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 1cddb2d52..71e8ab651 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -16,20 +16,16 @@ jobs: backend-tests: name: "Backend Server Tests" - uses: ./.github/workflows/partial-backend.yml + uses: ./.github/workflows/test-backend.yml frontend-tests: name: "Frontend Tests" - uses: ./.github/workflows/partial-frontend.yml + uses: ./.github/workflows/test-frontend.yml container-scanning: name: "Trivy Container Scanning" uses: ./.github/workflows/partial-trivy-container-scanning.yml - end-to-end: - name: "End-to-End Tests" - uses: ./.github/workflows/e2e.yml - code-ql: name: "CodeQL" uses: ./.github/workflows/codeql.yml @@ -37,3 +33,33 @@ jobs: actions: read contents: read security-events: write + + build-package: + name: "Build Python package" + uses: ./.github/workflows/build-package.yml + with: + tag: e2e + + end-to-end: + name: "End-to-End Tests" + needs: build-package + uses: ./.github/workflows/e2e.yml + + publish-image: + name: "Publish PR Image" + if: contains(github.event.pull_request.labels.*.name, 'build-image') + permissions: + contents: read + packages: write + # The id-token write permission is needed to connect to Depot.dev + # as part of the partial-builder.yml action. It needs to be declared + # in the parent action, as noted here: + # https://github.com/orgs/community/discussions/76409#discussioncomment-8131390 + id-token: write + needs: build-package + uses: ./.github/workflows/publish.yml + with: + tag: pr-${{ github.event.pull_request.number }} + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 55b0ec5d1..22b2b28b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,13 +7,19 @@ on: jobs: backend-tests: name: "Backend Server Tests" - uses: ./.github/workflows/partial-backend.yml + uses: ./.github/workflows/test-backend.yml frontend-tests: name: "Frontend Tests" - uses: ./.github/workflows/partial-frontend.yml + uses: ./.github/workflows/test-frontend.yml - build-release: + build-package: + name: Build Package + uses: ./.github/workflows/build-package.yml + with: + tag: release + + publish: permissions: contents: read packages: write @@ -23,10 +29,11 @@ jobs: # https://github.com/orgs/community/discussions/76409#discussioncomment-8131390 id-token: write name: Build Tagged Release - uses: ./.github/workflows/partial-builder.yml + uses: ./.github/workflows/publish.yml needs: - backend-tests - frontend-tests + - build-package with: tag: ${{ github.event.release.tag_name }} tags: | @@ -39,7 +46,7 @@ jobs: notify-discord: name: Notify Discord needs: - - build-release + - publish runs-on: ubuntu-latest steps: - name: Discord notification @@ -52,7 +59,7 @@ jobs: update-image-tags: name: Update image tag in sample docker-compose files needs: - - build-release + - publish runs-on: ubuntu-latest permissions: contents: write diff --git a/.github/workflows/partial-backend.yml b/.github/workflows/test-backend.yml similarity index 100% rename from .github/workflows/partial-backend.yml rename to .github/workflows/test-backend.yml diff --git a/.github/workflows/partial-frontend.yml b/.github/workflows/test-frontend.yml similarity index 100% rename from .github/workflows/partial-frontend.yml rename to .github/workflows/test-frontend.yml