From d0f71d9b0ef49543f311753014097fa2d39b96e1 Mon Sep 17 00:00:00 2001 From: Hendrik Kleinwaechter Date: Tue, 19 Dec 2023 13:08:50 +0100 Subject: [PATCH] Runs tests on push (#317) * Runs tests on push * Move out config --- .../test-book-website-pull-request.yml | 14 +++++++++++ .github/workflows/test-book-website-push.yml | 14 +++++++++++ .github/workflows/test-book-website.yml | 25 ++++++++----------- 3 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/test-book-website-pull-request.yml create mode 100644 .github/workflows/test-book-website-push.yml diff --git a/.github/workflows/test-book-website-pull-request.yml b/.github/workflows/test-book-website-pull-request.yml new file mode 100644 index 0000000..fbb4757 --- /dev/null +++ b/.github/workflows/test-book-website-pull-request.yml @@ -0,0 +1,14 @@ +name: Test building book and website with custom image + +on: + pull_request: + +jobs: + build-and-push-image: + uses: ./.github/workflows/docker-build-push.yml + + test-building-book-website: + needs: build-and-push-image + uses: ./.github/workflows/test-book-website.yml + with: + docker-image: ghcr.io/${{ github.repository }}:${{ github.event.pull_request.head.ref }} diff --git a/.github/workflows/test-book-website-push.yml b/.github/workflows/test-book-website-push.yml new file mode 100644 index 0000000..69c85c8 --- /dev/null +++ b/.github/workflows/test-book-website-push.yml @@ -0,0 +1,14 @@ +name: Test building book and website with default image + +on: + push: + +jobs: + build-and-push-image: + uses: ./.github/workflows/docker-build-push.yml + + test-building-book-website: + needs: build-and-push-image + uses: ./.github/workflows/test-book-website.yml + with: + docker-image: ghcr.io/${{ github.repository }}:latest diff --git a/.github/workflows/test-book-website.yml b/.github/workflows/test-book-website.yml index 24c9e2e..15671fc 100644 --- a/.github/workflows/test-book-website.yml +++ b/.github/workflows/test-book-website.yml @@ -1,17 +1,14 @@ -name: Test building book and website +name: Test book and website for given image on: - pull_request: - -env: - IMAGE: ghcr.io/${{ github.repository }}:${{ github.event.pull_request.head.ref }} + workflow_call: + inputs: + docker-image: + required: true + type: string jobs: - build-and-push-image: - uses: ./.github/workflows/docker-build-push.yml - - test-building-book-website: - needs: build-and-push-image + test-book-website: runs-on: ubuntu-latest steps: - name: Set up git repository @@ -19,7 +16,7 @@ jobs: - name: Print dependency versions uses: addnab/docker-run-action@v3 with: - image: ${{ env.IMAGE }} + image: ${{ inputs.docker-image }} options: -v ${{ github.workspace }}:/app run: | cd /app/book @@ -27,7 +24,7 @@ jobs: - name: Print build variables uses: addnab/docker-run-action@v3 with: - image: ${{ env.IMAGE }} + image: ${{ inputs.docker-image }} options: -v ${{ github.workspace }}:/app run: | cd /app/book @@ -35,7 +32,7 @@ jobs: - name: Test baking the release versions uses: addnab/docker-run-action@v3 with: - image: ${{ env.IMAGE }} + image: ${{ inputs.docker-image }} options: -v ${{ github.workspace }}:/app run: | cd /app/book @@ -51,7 +48,7 @@ jobs: - name: Test building website uses: addnab/docker-run-action@v3 with: - image: ${{ env.IMAGE }} + image: ${{ inputs.docker-image }} options: -v ${{ github.workspace }}:/app run: | cd /app/book