From d419b290fd5c57c439ba50b17f45872b6e8f517c Mon Sep 17 00:00:00 2001 From: Lucas Petrino Date: Wed, 13 Nov 2024 10:34:22 +1300 Subject: [PATCH 1/5] ci: build images on push and daily --- .gitea/workflows/docker.yml | 91 +++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .gitea/workflows/docker.yml diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml new file mode 100644 index 0000000..b53531e --- /dev/null +++ b/.gitea/workflows/docker.yml @@ -0,0 +1,91 @@ +name: Docker + +on: + push: + branches: [ "ci-test" ] + tags: [ 'v*.*.*' ] + schedule: + - cron: "0 0 * * *" + +env: + REGISTRY: git.119.224.65.18.sslip.io + +jobs: + build: + + runs-on: ubuntu-22.04 + + strategy: + fail-fast: false + matrix: + base_image: [ubuntu-22.04, ubuntu-latest] + include: + - dockerfile: ./images/qt.dockerfile + image: git.119.224.65.18.sslip.io/siteorg/action-image-qt + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Install the cosign tool except on PR + # https://github.com/sigstore/cosign-installer + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0 + with: + cosign-release: 'v2.2.4' + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 + with: + driver-opts: network=host + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 + with: + images: ${{ matrix.image }}:${{ matrix.base_image }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 + with: + context: . + file: ${{ matrix.dockerfile }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + # Sign the resulting Docker image digest except on PRs. + # This will only write to the public Rekor transparency log when the Docker + # repository is public to avoid leaking data. If you would like to publish + # transparency data even for private images, pass --force to cosign below. + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable + TAGS: ${{ steps.meta.outputs.tags }} + DIGEST: ${{ steps.build-and-push.outputs.digest }} + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} \ No newline at end of file -- 2.34.1 From 626d1114c768c27e9ca2714d99adbbe3da1e37f7 Mon Sep 17 00:00:00 2001 From: Lucas Petrino Date: Wed, 13 Nov 2024 10:40:08 +1300 Subject: [PATCH 2/5] ci: fix matrix --- .gitea/workflows/docker.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml index b53531e..1266b26 100644 --- a/.gitea/workflows/docker.yml +++ b/.gitea/workflows/docker.yml @@ -18,10 +18,13 @@ jobs: strategy: fail-fast: false matrix: - base_image: [ubuntu-22.04, ubuntu-latest] include: - dockerfile: ./images/qt.dockerfile image: git.119.224.65.18.sslip.io/siteorg/action-image-qt + base: ubuntu-22.04 + - dockerfile: ./images/qt.dockerfile + image: git.119.224.65.18.sslip.io/siteorg/action-image-qt + base: ubuntu-latest steps: - name: Checkout repository @@ -59,7 +62,7 @@ jobs: id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 with: - images: ${{ matrix.image }}:${{ matrix.base_image }} + images: ${{ matrix.image }}:${{ matrix.base }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action -- 2.34.1 From 21f8b8700ffdbc0e686a9bdfafc179b99acfe1f5 Mon Sep 17 00:00:00 2001 From: Lucas Petrino Date: Wed, 13 Nov 2024 10:42:16 +1300 Subject: [PATCH 3/5] fix: docker image tag format --- .gitea/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml index 1266b26..5cb5cf1 100644 --- a/.gitea/workflows/docker.yml +++ b/.gitea/workflows/docker.yml @@ -62,7 +62,7 @@ jobs: id: meta uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 with: - images: ${{ matrix.image }}:${{ matrix.base }} + images: ${{ matrix.image }}-${{ matrix.base }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action -- 2.34.1 From c9a957ae3b226b8c1b1a0b2e1baa8d7c548c4a5f Mon Sep 17 00:00:00 2001 From: Lucas Petrino Date: Wed, 13 Nov 2024 11:07:32 +1300 Subject: [PATCH 4/5] ci: remove image signing --- .gitea/workflows/docker.yml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml index 5cb5cf1..1791035 100644 --- a/.gitea/workflows/docker.yml +++ b/.gitea/workflows/docker.yml @@ -76,19 +76,4 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha - cache-to: type=gha,mode=max - - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable - TAGS: ${{ steps.meta.outputs.tags }} - DIGEST: ${{ steps.build-and-push.outputs.digest }} - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} \ No newline at end of file + cache-to: type=gha,mode=max \ No newline at end of file -- 2.34.1 From a6060456bd9611c673562c0e4d91a119773d68d9 Mon Sep 17 00:00:00 2001 From: Lucas Petrino Date: Wed, 13 Nov 2024 11:09:31 +1300 Subject: [PATCH 5/5] ci: build on any branch --- .gitea/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml index 1791035..7ef3ec8 100644 --- a/.gitea/workflows/docker.yml +++ b/.gitea/workflows/docker.yml @@ -2,7 +2,7 @@ name: Docker on: push: - branches: [ "ci-test" ] + branches: [ "*" ] tags: [ 'v*.*.*' ] schedule: - cron: "0 0 * * *" -- 2.34.1