From 73492bbed971b81b8e762b805c0054968c021cd2 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Wed, 30 Nov 2022 19:16:53 +0100 Subject: [PATCH] Gha test. (#156) * Gha test. * A test. * Fix build. * Another test. * Another test. * Also update release. --- .github/workflows/dev.yml | 108 +++++++++++---------------------- .github/workflows/release.yml | 111 +++++++++++++--------------------- 2 files changed, 75 insertions(+), 144 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 59b3d15c..09e13c86 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -21,84 +21,48 @@ jobs: - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4.3.2 - - name: Calculate Version - env: - BUILD_NUMBER: ${{ github.run_number }} - run: | - echo "BUILD_NUMBER=$(($BUILD_NUMBER + 1000))" >> $GITHUB_ENV - - name: Set up QEMU uses: docker/setup-qemu-action@v2.1.0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2.2.1 - - name: Cache Docker layers - uses: actions/cache@v3.0.11 + - name: Login to Docker Hub + uses: docker/login-action@v2.1.0 with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: BUILD uses: docker/build-push-action@v3.2.0 with: - push: false - load: true - build-args: "NOTIFO__VERSION=1.0.0-dev-${{ env.BUILD_NUMBER }}" - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new - tags: notifo-tmp - - - name: Export Image - run: docker save notifo-tmp | gzip > notifo-tmp.tar.gz - - - name: Save Image to Cache - uses: actions/cache@v3.0.11 - with: - path: notifo-tmp.tar.gz - key: notifo-dev-image-${{ github.sha }} - - - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + tags: squidex/notifo-build test: needs: build runs-on: ubuntu-latest steps: - - name: Calculate Version - env: - BUILD_NUMBER: ${{ github.run_number }} - run: | - echo "BUILD_NUMBER=$(($BUILD_NUMBER + 1000))" >> $GITHUB_ENV - - name: Checkout uses: actions/checkout@v3.1.0 - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4.3.2 - - - name: Get Image From Cache - uses: actions/cache@v3.0.11 - with: - path: notifo-tmp.tar.gz - key: notifo-dev-image-${{ github.sha }} - - - name: Load Image - run: docker load < notifo-tmp.tar.gz + + - name: Pull from Cache + run: docker pull squidex/notifo-build - name: Replace Image Name1 uses: mikefarah/yq@v4.9.1 with: - cmd: yq e '.services.notifo1.image = "notifo-tmp"' -i backend/tests/docker-compose.yml + cmd: yq e '.services.notifo1.image = "squidex/notifo-build"' -i backend/tests/docker-compose.yml - name: Replace Image Name2 uses: mikefarah/yq@v4.9.1 with: - cmd: yq e '.services.notifo2.image = "notifo-tmp"' -i backend/tests/docker-compose.yml + cmd: yq e '.services.notifo2.image = "squidex/notifo-build"' -i backend/tests/docker-compose.yml - name: Inject Google Credentials run: mkdir secrets && echo "$GOOGLE__KEYFILE" >| secrets/keyfile.json @@ -144,7 +108,7 @@ jobs: if: failure() uses: jwalton/gh-docker-logs@v2.2.1 with: - images: 'notifo-tmp,squidex/resizer' + images: 'squidex/notifo-build,squidex/resizer' tail: '100' - name: Cleanup Test @@ -155,42 +119,38 @@ jobs: publish: needs: test runs-on: ubuntu-latest + if: github.event_name != 'pull_request' steps: + - name: Checkout + uses: actions/checkout@v3.1.0 + + - name: Inject slug/short variables + uses: rlespinasse/github-slug-action@v4.3.2 + - name: Calculate Version env: BUILD_NUMBER: ${{ github.run_number }} run: | echo "BUILD_NUMBER=$(($BUILD_NUMBER + 1000))" >> $GITHUB_ENV - - name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v4.3.2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2.1.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2.2.1 - name: Login to Docker Hub uses: docker/login-action@v2.1.0 - if: github.event_name != 'pull_request' with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Get Image From Cache - if: github.event_name != 'pull_request' - uses: actions/cache@v3.0.11 + - name: BUILD + uses: docker/build-push-action@v3.2.0 with: - path: notifo-tmp.tar.gz - key: notifo-dev-image-${{ github.sha }} - - - name: Load Image - if: github.event_name != 'pull_request' - run: docker load < notifo-tmp.tar.gz - - - name: Rename Tags - if: github.event_name != 'pull_request' - run: | - docker tag notifo-tmp squidex/notifo:dev - docker tag notifo-tmp squidex/notifo:dev-${{ env.BUILD_NUMBER }} - - - name: Push Tags - if: github.event_name != 'pull_request' - run: | - docker push squidex/notifo:dev - docker push squidex/notifo:dev-${{ env.BUILD_NUMBER }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + tags: | + squidex/notifo:dev + squidex/notifo:dev-${{ env.BUILD_NUMBER }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 566c1c89..ad8a2606 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,37 +22,20 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2.2.1 - - name: Cache Docker layers - uses: actions/cache@v3.0.11 + - name: Login to Docker Hub + uses: docker/login-action@v2.1.0 with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: BUILD uses: docker/build-push-action@v3.2.0 with: - push: false - load: true - tags: notifo-tmp + push: true build-args: "NOTIFO__VERSION=${{ env.GITHUB_REF_SLUG }}" - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new - - - name: Export Image - run: docker save notifo-tmp | gzip > notifo-tmp.tar.gz - - - name: Save Image to Cache - uses: actions/cache@v3.0.11 - with: - path: notifo-tmp.tar.gz - key: notifo-release-image-${{ github.sha }} - - - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + cache-from: type=gha + cache-to: type=gha,mode=max + tags: squidex/notifo-build test: needs: build @@ -63,25 +46,19 @@ jobs: - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4.3.2 - - - name: Get Image From Cache - uses: actions/cache@v3.0.11 - with: - path: notifo-tmp.tar.gz - key: notifo-release-image-${{ github.sha }} - - - name: Load Image - run: docker load < notifo-tmp.tar.gz + + - name: Pull from Cache + run: docker pull squidex/notifo-build - name: Replace Image Name1 uses: mikefarah/yq@v4.9.1 with: - cmd: yq e '.services.notifo1.image = "notifo-tmp"' -i backend/tests/docker-compose.yml + cmd: yq e '.services.notifo1.image = "squidex/notifo-build"' -i backend/tests/docker-compose.yml - name: Replace Image Name2 uses: mikefarah/yq@v4.9.1 with: - cmd: yq e '.services.notifo2.image = "notifo-tmp"' -i backend/tests/docker-compose.yml + cmd: yq e '.services.notifo2.image = "squidex/notifo-build"' -i backend/tests/docker-compose.yml - name: Inject Google Credentials run: mkdir secrets && echo "$GOOGLE__KEYFILE" >| secrets/keyfile.json @@ -127,7 +104,7 @@ jobs: if: failure() uses: jwalton/gh-docker-logs@v2.2.1 with: - images: 'notifo-tmp,squidex/resizer' + images: 'squidex/notifo-build,squidex/resizer' tail: '100' - name: Cleanup Test @@ -139,15 +116,12 @@ jobs: needs: test runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v3.1.0 + - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4.3.2 - - name: Login to Docker Hub - uses: docker/login-action@v2.1.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Get Major Version id: version uses: rishabhgupta/split-by@v1 @@ -155,26 +129,29 @@ jobs: string: "${{ env.GITHUB_REF_SLUG }}" split-by: "." - - name: Get Image From Cache - uses: actions/cache@v3.0.11 - with: - path: notifo-tmp.tar.gz - key: notifo-release-image-${{ github.sha }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2.1.0 - - name: Load Image - run: docker load < notifo-tmp.tar.gz + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2.2.1 - - name: Rename Tags - run: | - docker tag notifo-tmp squidex/notifo:latest - docker tag notifo-tmp squidex/notifo:${{ env.GITHUB_REF_SLUG }} - docker tag notifo-tmp squidex/notifo:${{ steps.version.outputs._0 }} + - name: Login to Docker Hub + uses: docker/login-action@v2.1.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - - name: Push Tags - run: | - docker push squidex/notifo:latest - docker push squidex/notifo:${{ env.GITHUB_REF_SLUG }} - docker push squidex/notifo:${{ steps.version.outputs._0 }} + - name: BUILD + uses: docker/build-push-action@v3.2.0 + with: + push: true + build-args: "NOTIFO__VERSION=${{ env.GITHUB_REF_SLUG }}" + cache-from: type=gha + cache-to: type=gha,mode=max + tags: | + squidex/notifo:latest + squidex/notifo:${{ env.GITHUB_REF_SLUG }} + squidex/notifo:${{ steps.version.outputs._0 }} release: needs: publish @@ -185,21 +162,15 @@ jobs: - name: Inject slug/short variables uses: rlespinasse/github-slug-action@v4.3.2 - - - name: Get Image From Cache - uses: actions/cache@v3.0.11 - with: - path: notifo-tmp.tar.gz - key: notifo-release-image-${{ github.sha }} - - - name: Load Image - run: docker load < notifo-tmp.tar.gz + + - name: Pull from Cache + run: docker pull squidex/notifo-build - name: Make directories run: sudo mkdir /build /release - name: Create container - run: docker create --name notifo-container notifo-tmp:latest + run: docker create --name notifo-container squidex/notifo-build - name: Get binaries run: sudo docker cp notifo-container:/app/. /build