Building CC-Job-Image-Base #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build CC-Job-Image-Base | |
| run-name: Building CC-Job-Image-Base | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| environment: build | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| packages: write | |
| env: | |
| platforms: linux/amd64,linux/arm64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Git Identity | |
| run: | | |
| git config --global --add safe.directory $PWD | |
| git config --global user.name 'Gardener-CICD Bot' | |
| git config --global user.email 'gardener.ci.user@gmail.com' | |
| - name: Setup Docker-Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Setup QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: ${{ env.platforms }} | |
| - name: docker-auth | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| registry: ghcr.io | |
| - name: Set lowercase repository owner | |
| id: repo_owner_lower | |
| run: echo "::set-output name=lower_repo_owner::$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" | |
| - name: Build and Publish CC-Job-Image-Base | |
| uses: docker/build-push-action@v6 | |
| with: | |
| push: true | |
| platforms: ${{ env.platforms }} | |
| tags: ghcr.io/${{ steps.repo_owner_lower.outputs.lower_repo_owner }}/cc-utils/job-image-base:latest | |
| file: Dockerfile.job-image-base | |
| - name: Get latest Docker version | |
| id: docker_version | |
| run: | | |
| greatest_version=$(curl -sL \ | |
| https://download.docker.com/linux/static/stable/x86_64 \ | |
| | cut -d\" -f2 \ | |
| | grep "docker-[[:digit:]]" \ | |
| | cut -d- -f2 \ | |
| | cut -d. -f1,2,3 \ | |
| | sort -Vr \ | |
| | head -1) | |
| echo "DOCKER_VERSION=$greatest_version" >> $GITHUB_ENV | |
| echo "Latest Docker version: $greatest_version" | |
| - name: Get latest Buildx version | |
| id: buildx_version | |
| run: | | |
| greatest_version=$(curl -sL https://api.github.com/repos/docker/buildx/releases \ | |
| -H 'Accept: application/json' \ | |
| | jq -r .[].tag_name \ | |
| | sort -Vr \ | |
| | head -1) | |
| echo "BUILDX_VERSION=$greatest_version" >> $GITHUB_ENV | |
| echo "Latest Buildx version: $greatest_version" | |
| - name: Update Dockerfile with latest versions | |
| run: | | |
| sed -i "s/DOCKER_VERSION=.*/DOCKER_VERSION=${{ env.DOCKER_VERSION }}/" Dockerfile.job-image-base | |
| sed -i "s/DOCKER_BUILDX_VERSION=.*/DOCKER_BUILDX_VERSION=${{ env.BUILDX_VERSION }}/" Dockerfile.job-image-base | |
| git add Dockerfile.job-image-base | |
| git commit -m "Update Dockerfile to use Docker ${{ env.DOCKER_VERSION }} and Buildx ${{ env.BUILDX_VERSION }}" | |
| git checkout -b update-dockerfile | |
| git push origin update-dockerfile | |
| - name: Create Pull Request | |
| run: | | |
| gh pr create \ | |
| -B master \ | |
| -H update-dockerfile \ | |
| --title "Update Dockerfile with latest Docker and Buildx versions" \ | |
| --body "This PR updates the Dockerfile to use the latest versions:\n\n- Docker: `${{ env.DOCKER_VERSION }}`\n- Buildx: `${{ env.BUILDX_VERSION }}`." | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |