From fbd7128e1cfe690946e4ad24da4577f1d33dee12 Mon Sep 17 00:00:00 2001 From: VictorDidier Date: Tue, 23 Jan 2024 15:43:06 +0100 Subject: [PATCH 1/5] github action for docker build --- .github/workflows/docker-publish.yml | 85 ++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..21b363a --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,85 @@ +name: publish docker container for basicpy + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: [push] + #release: + # types: published + #pull_request: + # branches: [ "main" ] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + # This is used to complete the identity challenge + # with sigstore/fulcio when running outside of PRs. + id-token: write + + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Checkout repository + uses: actions/checkout@v3 + + # 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@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0 + with: + cosign-release: 'v1.11.0' + + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf + + # 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@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Get the tag name + run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + # 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@ac9327eae2b366085ac7f6a2d02df8aa8ead720a + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 70a4b4bfb3509fc99fa8049256c457e98563c905 Mon Sep 17 00:00:00 2001 From: VictorDidier Date: Tue, 23 Jan 2024 17:09:46 +0100 Subject: [PATCH 2/5] updated docker-publish.yml --- .github/workflows/docker-publish.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 21b363a..c95a953 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,15 +1,15 @@ -name: publish docker container for basicpy +name: Docker # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support # documentation. -on: [push] - #release: - # types: published - #pull_request: - # branches: [ "main" ] +on: + release: + types: [ "published" ] + pull_request: + branches: [ "main" ] env: # Use docker.io for Docker Hub if empty @@ -30,19 +30,16 @@ jobs: id-token: write steps: - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Checkout repository uses: actions/checkout@v3 # Install the cosign tool except on PR # https://github.com/sigstore/cosign-installer - - name: Install cosign + - name: Install Cosign if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0 + uses: sigstore/cosign-installer@v3.1.1 with: - cosign-release: 'v1.11.0' + cosign-release: 'v2.2.1' # Workaround: https://github.com/docker/build-push-action/issues/461 - name: Setup Docker buildx From 56cb46ed7b43dba75010acb071801a40fdd2d569 Mon Sep 17 00:00:00 2001 From: VictorDidier Date: Tue, 23 Jan 2024 17:12:56 +0100 Subject: [PATCH 3/5] updated docker-publish.yml --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index c95a953..fc47273 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,7 +7,7 @@ name: Docker on: release: - types: [ "published" ] + types: [ "push" ] pull_request: branches: [ "main" ] From 3449f33933577cfcccea717016d8cfcc61fb6712 Mon Sep 17 00:00:00 2001 From: VictorDidier Date: Tue, 23 Jan 2024 17:14:13 +0100 Subject: [PATCH 4/5] updated docker-publish.yml --- .github/workflows/docker-publish.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index fc47273..896562b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -5,11 +5,11 @@ name: Docker # separate terms of service, privacy policy, and support # documentation. -on: - release: - types: [ "push" ] - pull_request: - branches: [ "main" ] +on: [ "push" ] + #release: + # types: [ "push" ] + #pull_request: + # branches: [ "main" ] env: # Use docker.io for Docker Hub if empty From f78658f7a23c2ab3b436b34b2ed61b5033b18082 Mon Sep 17 00:00:00 2001 From: VictorDidier <68292394+VictorDidier@users.noreply.github.com> Date: Fri, 26 Jan 2024 13:12:58 +0100 Subject: [PATCH 5/5] Update docker-publish.yml Changed release on: publish --- .github/workflows/docker-publish.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 896562b..4906664 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -5,11 +5,11 @@ name: Docker # separate terms of service, privacy policy, and support # documentation. -on: [ "push" ] - #release: - # types: [ "push" ] - #pull_request: - # branches: [ "main" ] +on: + release: + types: [ "published" ] + pull_request: + branches: [ "main" ] env: # Use docker.io for Docker Hub if empty @@ -79,4 +79,4 @@ jobs: platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }}