]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
gh actions: add WF for building and pushing images manually
authorromeroalx <alexis.romero@open-xchange.com>
Tue, 14 May 2024 15:43:26 +0000 (17:43 +0200)
committerromeroalx <alexis.romero@open-xchange.com>
Tue, 14 May 2024 15:47:09 +0000 (17:47 +0200)
.github/workflows/build-docker-images-dispatch.yml [new file with mode: 0644]

diff --git a/.github/workflows/build-docker-images-dispatch.yml b/.github/workflows/build-docker-images-dispatch.yml
new file mode 100644 (file)
index 0000000..3031906
--- /dev/null
@@ -0,0 +1,90 @@
+---
+name: Trigger specific image build
+
+on:
+  workflow_dispatch:
+    inputs:
+      product:
+        required: true
+        description: Product to build
+        type: choice
+        options:
+        - auth
+        - recursor
+        - dnsdist
+      ref:
+        description: git branch or tag to checkout (e.g. rec-5.0.0-rc1)
+        type: string
+        default: master
+        required: false
+      platforms:
+        description: target platform(s)
+        type: string
+        default: linux/arm64/v8,linux/amd64
+        required: false
+      build-args:
+        description: build-time variables (e.g. DOCKER_FAKE_RELEASE=YES when building for tags)
+        type: string
+        default: ''
+        required: false
+      push:
+        description: push image to DockerHub
+        type: boolean
+        required: true
+
+permissions: # least privileges, see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
+  contents: read
+  actions: read
+
+jobs:
+  prepare:
+    runs-on: ubuntu-22.04
+    outputs:
+      image-tag: ${{ steps.get-image-tag.outputs.tag }}
+      image-name: ${{ steps.get-image-metadata.outputs.name }}
+      image-description: ${{ steps.get-image-metadata.outputs.description }}
+    steps:
+      - run: |
+          echo '${{ inputs.ref }}' | egrep -qq '^auth-.*|^rec-.*|^dnsdist-.*' && tag=$(echo '${{ inputs.ref }}' | cut -d '-' -f 2-)
+          echo "tag=$tag" >> $GITHUB_OUTPUT
+        id: get-image-tag
+      - run: |
+          if $(echo '${{ inputs.ref }}' | egrep -qq '^auth-.*|^rec-.*|^dnsdist-.*'); then
+            echo "version=$(echo '${{ inputs.ref }}' | cut -d '-' -f 2 | awk -F'.' '{print $1$2}')" >> $GITHUB_ENV
+            echo "branch=$(echo '${{ inputs.ref }}' | cut -d '-' -f 2- | awk -F'.' '{print "v"$1"."$2".x"}')" >> $GITHUB_ENV
+          else
+            echo "version=$(echo '${{ inputs.ref }}' | tr '/' '-')" >> $GITHUB_ENV
+            echo "branch=${{ inputs.ref }}" >> $GITHUB_ENV
+          fi
+      - run: |
+          if $(echo '${{ inputs.product }}'| grep -qq auth); then
+            echo '${{ inputs.ref }}' | egrep -qq '^auth-.*' && description='PowerDNS Authoritative Server '$branch || description='EXPERIMENTAL pdns auth image'
+            echo "name=pdns-auth-$version" >> $GITHUB_OUTPUT
+          elif (echo '${{ inputs.product }}'| grep -qq recursor); then
+            echo '${{ inputs.ref }}' | egrep -qq '^rec-.*' && description='PowerDNS Recursor '$branch || description='EXPERIMENTAL pdns recursor image'
+            echo "name=pdns-recursor-$version" >> $GITHUB_OUTPUT
+          else
+            echo '${{ inputs.ref }}' | egrep -qq '^dnsdist-.*' && description='PowerDNS DNSDist '$branch || description='EXPERIMENTAL dnsdist image'
+            echo "name=dnsdist-$version" >> $GITHUB_OUTPUT
+          fi
+          echo "description=$description" >> $GITHUB_OUTPUT
+        id: get-image-metadata
+
+  call-build-docker-image:
+    uses: PowerDNS/pdns/.github/workflows/build-docker-images.yml@master
+    needs: prepare
+    with:
+      product: ${{ inputs.product }}
+      ref: ${{ inputs.ref }}
+      image-name: ${{ needs.prepare.outputs.image-name }}
+      image-tags: |-
+        latest
+        ${{ needs.prepare.outputs.image-tag }}
+      image-description: ${{ needs.prepare.outputs.image-description }}
+      platforms: ${{ inputs.platforms }}
+      build-args: ${{ inputs.build-args }}
+      push: ${{ inputs.push }}
+    secrets:
+      DOCKERHUB_ORGANIZATION_NAME: ${{ secrets.DOCKERHUB_ORGANIZATION_NAME }}
+      DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
+      DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}