|
| 1 | +name: 'build docker images: k8s tools' |
| 2 | + |
| 3 | +on: |
| 4 | + #push: |
| 5 | + # branches: |
| 6 | + # - 'main' |
| 7 | + # - 'master' |
| 8 | + # paths: |
| 9 | + # - 'k8s-tools.alpine.Dockerfile' |
| 10 | + # - '.github/workflows/build_docker_images-k8s.yaml' |
| 11 | + workflow_dispatch: |
| 12 | + schedule: |
| 13 | + - cron: '30 5 28 * *' # At 05:30 on day-of-month 28. |
| 14 | + |
| 15 | +defaults: |
| 16 | + run: |
| 17 | + shell: bash |
| 18 | + |
| 19 | +jobs: |
| 20 | + docker: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Shell-Script |
| 27 | + id: script |
| 28 | + run: | |
| 29 | + BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" |
| 30 | + BUILD_DATE_NUMERIC="${BUILD_DATE//[^[:digit:]]/}" |
| 31 | + COMMIT_HASH=${GITHUB_SHA::7} |
| 32 | + GITHUB_REPO=${GITHUB_REPOSITORY,,} |
| 33 | + GITHUB_REPO_SHORT=${GITHUB_REPO#*/} |
| 34 | + GITHUB_REPO_SHORT=${GITHUB_REPO_SHORT#"docker-"} |
| 35 | + DOCKER_REPO=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPO_SHORT} |
| 36 | + REDHAT_QUAY_REPO=${{ secrets.REDHAT_QUAY_USERNAME }}/${GITHUB_REPO_SHORT} |
| 37 | + |
| 38 | + # Set output parameters to action. |
| 39 | + echo "build_date=${BUILD_DATE}" >> "$GITHUB_OUTPUT" |
| 40 | + echo "build_date_numeric=${BUILD_DATE_NUMERIC}" >> "$GITHUB_OUTPUT" |
| 41 | + echo "commit_hash=${COMMIT_HASH}" >> "$GITHUB_OUTPUT" |
| 42 | + echo "github_repo=${GITHUB_REPO}" >> "$GITHUB_OUTPUT" |
| 43 | + echo "docker_repo=${DOCKER_REPO}" >> "$GITHUB_OUTPUT" |
| 44 | + echo "redhat_quay_repo=${REDHAT_QUAY_REPO}" >> "$GITHUB_OUTPUT" |
| 45 | +
|
| 46 | + - name: Set up QEMU |
| 47 | + id: qemu |
| 48 | + uses: docker/setup-qemu-action@v3 |
| 49 | + with: |
| 50 | + image: tonistiigi/binfmt:latest |
| 51 | + platforms: all |
| 52 | + |
| 53 | + - name: Set up Docker Buildx |
| 54 | + id: buildx |
| 55 | + uses: docker/setup-buildx-action@v3 |
| 56 | + |
| 57 | + - name: Login to GitHub Container Registry |
| 58 | + uses: docker/login-action@v3 |
| 59 | + with: |
| 60 | + registry: ghcr.io |
| 61 | + username: ${{ github.repository_owner }} |
| 62 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + |
| 64 | + - name: Login to DockerHub |
| 65 | + uses: docker/login-action@v3 |
| 66 | + with: |
| 67 | + registry: docker.io |
| 68 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 69 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 70 | + |
| 71 | + - name: Login to RED HAT Quay.io Container Registry |
| 72 | + uses: docker/login-action@v3 |
| 73 | + with: |
| 74 | + registry: quay.io |
| 75 | + username: ${{ secrets.REDHAT_QUAY_USERNAME }} |
| 76 | + password: ${{ secrets.REDHAT_QUAY_PASSWORD }} |
| 77 | + |
| 78 | + - name: Build |
| 79 | + uses: docker/build-push-action@v6 |
| 80 | + with: |
| 81 | + builder: ${{ steps.buildx.outputs.name }} |
| 82 | + context: . |
| 83 | + file: ./k8s-tools.alpine.Dockerfile |
| 84 | + platforms: linux/amd64,linux/arm64,linux/arm/v7 |
| 85 | + push: true |
| 86 | + #target: production |
| 87 | + build-args: | |
| 88 | + BUILD_DATE=${{steps.script.outputs.build_date}} |
| 89 | + VCS_REF=${{steps.script.outputs.commit_hash}} |
| 90 | + tags: | |
| 91 | + ghcr.io/${{steps.script.outputs.github_repo}}:k8s |
| 92 | + docker.io/${{steps.script.outputs.docker_repo}}:k8s |
| 93 | + quay.io/${{steps.script.outputs.redhat_quay_repo}}:k8s |
0 commit comments