|
| 1 | +name: Build and Publish CoreDNS Images |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - coredns_plugin |
| 8 | + - "release-*" |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +env: |
| 12 | + IMG_TAGS: ${{ github.sha }} ${{ github.ref_name }} |
| 13 | + IMG_REGISTRY_HOST: quay.io |
| 14 | + IMG_REGISTRY_ORG: kuadrant |
| 15 | + IMG_REGISTRY_REPO: coredns-kuadrant |
| 16 | + MAIN_BRANCH_NAME: main |
| 17 | + COREDNS_PLUGIN_NAME: coredns-kuadrant |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + name: Build and Push CoreDNS image |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Check out code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Add latest tag |
| 28 | + if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }} |
| 29 | + id: add-latest-tag |
| 30 | + run: | |
| 31 | + echo "IMG_TAGS=latest ${{ env.IMG_TAGS }}" >> $GITHUB_ENV |
| 32 | +
|
| 33 | + - name: Install qemu dependency |
| 34 | + run: | |
| 35 | + sudo apt-get update |
| 36 | + sudo apt-get install -y qemu-user-static |
| 37 | +
|
| 38 | + - name: Run make coredns-generate-demo-geo-db |
| 39 | + run: | |
| 40 | + make coredns-generate-demo-geo-db |
| 41 | +
|
| 42 | + - name: Build Image |
| 43 | + id: build-image |
| 44 | + uses: redhat-actions/buildah-build@v2 |
| 45 | + with: |
| 46 | + image: ${{ env.COREDNS_PLUGIN_NAME }} |
| 47 | + tags: ${{ env.IMG_TAGS }} |
| 48 | + platforms: linux/amd64,linux/arm64 |
| 49 | + context: ./coredns/plugin |
| 50 | + dockerfiles: | |
| 51 | + ./coredns/plugin/Dockerfile |
| 52 | +
|
| 53 | + - name: Print Build Info |
| 54 | + run: echo "Image = ${{ steps.build-image.outputs.image }}, Tags = ${{ steps.build-image.outputs.tags }}" |
| 55 | + |
| 56 | + - name: Push Image |
| 57 | + if: github.repository_owner == 'kuadrant' |
| 58 | + id: push-to-quay |
| 59 | + uses: redhat-actions/push-to-registry@v2 |
| 60 | + with: |
| 61 | + image: ${{ steps.build-image.outputs.image }} |
| 62 | + tags: ${{ steps.build-image.outputs.tags }} |
| 63 | + registry: ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }} |
| 64 | + username: ${{ secrets.IMG_REGISTRY_USERNAME }} |
| 65 | + password: ${{ secrets.IMG_REGISTRY_TOKEN }} |
| 66 | + |
| 67 | + - name: Print Image URL |
| 68 | + run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" |
0 commit comments