From 0e85950f746ded8f2fe3c9b6c8089bea45973dd3 Mon Sep 17 00:00:00 2001 From: erseco Date: Wed, 18 Oct 2023 16:00:14 +0100 Subject: [PATCH] Upgrade docker hub description, code cleanup and fix #37 and fix #39 --- .github/workflows/build.yml | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8109430..5ccd7db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,28 +8,28 @@ jobs: buildx: runs-on: ubuntu-latest steps: + # Step 1: Checkout the code - name: Checkout uses: actions/checkout@v4 + # Step 2: Prepare variables for building and tagging the image - name: Prepare id: prepare run: | DOCKER_IMAGE=erseco/alpine-moodle DOCKER_PLATFORMS=linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x - VERSION=${GITHUB_REF#refs/*/} TAGS="${DOCKER_IMAGE}:${VERSION}" - if [[ $GITHUB_REF == refs/tags/* ]]; then TAGS="$TAGS,${DOCKER_IMAGE}:latest" fi if [[ $VERSION == "master" ]]; then TAGS="$TAGS,${DOCKER_IMAGE}:beta" fi - echo ::set-output name=platforms::${DOCKER_PLATFORMS} echo ::set-output name=tags::${TAGS} + # Step 3: Set up QEMU for multi-platform builds - name: Set up QEMU id: qemu uses: docker/setup-qemu-action@v3 @@ -37,10 +37,12 @@ jobs: image: tonistiigi/binfmt:latest platforms: all + # Step 4: Set up Docker Buildx - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 id: buildx + # Step 5: Login to DockerHub - name: Login to DockerHub if: github.event_name != 'pull_request' uses: docker/login-action@v3 @@ -48,15 +50,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build - run: | - docker buildx build . - - - name: Test - run: | - docker-compose version - docker-compose --file docker-compose.test.yml up --exit-code-from sut --timeout 10 --build - + # Step 6: Build and Push (if not a PR) - name: Build and push uses: docker/build-push-action@v5 with: @@ -65,9 +59,22 @@ jobs: tags: ${{ steps.prepare.outputs.tags }} platforms: ${{ steps.prepare.outputs.platforms }} + # Step 6.5: Debug Build for PRs + - name: Debug Build on PR + if: github.event_name == 'pull_request' + run: | + docker buildx build --load . + + # Step 7: Test the built image + - name: Test + run: | + docker-compose version + docker-compose --file docker-compose.test.yml up --exit-code-from sut --timeout 10 --build + + # Step 8: Update Docker Hub Description - name: Docker Hub Description uses: peter-evans/dockerhub-description@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - short-description: ${{ github.event.repository.description }} \ No newline at end of file + short-description: ${{ github.event.repository.description }}