Build and Push containerd Images #34
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 and Push containerd Images | |
| on: | |
| schedule: | |
| - cron: "0 17 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - system: ubuntu | |
| dockerfile: Dockerfile_ubuntu | |
| tag_prefix: ubuntu | |
| - system: debian | |
| dockerfile: Dockerfile_debian | |
| tag_prefix: debian | |
| - system: alpine | |
| dockerfile: Dockerfile_alpine | |
| tag_prefix: alpine | |
| - system: almalinux | |
| dockerfile: Dockerfile_almalinux | |
| tag_prefix: almalinux | |
| - system: rockylinux | |
| dockerfile: Dockerfile_rockylinux | |
| tag_prefix: rockylinux | |
| - system: openeuler | |
| dockerfile: Dockerfile_openeuler | |
| tag_prefix: openeuler | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU (multi-arch) | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and export amd64 tar | |
| run: | | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| --file dockerfiles/${{ matrix.dockerfile }} \ | |
| --tag spiritlhl/${{ matrix.tag_prefix }}:latest \ | |
| --output type=docker \ | |
| dockerfiles/ | |
| docker save spiritlhl/${{ matrix.tag_prefix }}:latest | gzip > spiritlhl_${{ matrix.tag_prefix }}_amd64.tar.gz | |
| echo "amd64 tar size: $(du -sh spiritlhl_${{ matrix.tag_prefix }}_amd64.tar.gz)" | |
| - name: Build and export arm64 tar | |
| run: | | |
| docker buildx build \ | |
| --platform linux/arm64 \ | |
| --file dockerfiles/${{ matrix.dockerfile }} \ | |
| --tag spiritlhl/${{ matrix.tag_prefix }}:latest \ | |
| --output type=docker \ | |
| dockerfiles/ | |
| docker save spiritlhl/${{ matrix.tag_prefix }}:latest | gzip > spiritlhl_${{ matrix.tag_prefix }}_arm64.tar.gz | |
| echo "arm64 tar size: $(du -sh spiritlhl_${{ matrix.tag_prefix }}_arm64.tar.gz)" | |
| - name: Upload amd64 tar to GitHub Release | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: spiritlhl_${{ matrix.tag_prefix }}_amd64.tar.gz | |
| asset_name: spiritlhl_${{ matrix.tag_prefix }}_amd64.tar.gz | |
| tag: ${{ matrix.tag_prefix }} | |
| overwrite: true | |
| body: "containerd image for ${{ matrix.tag_prefix }} (amd64 + arm64)" | |
| - name: Upload arm64 tar to GitHub Release | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: spiritlhl_${{ matrix.tag_prefix }}_arm64.tar.gz | |
| asset_name: spiritlhl_${{ matrix.tag_prefix }}_arm64.tar.gz | |
| tag: ${{ matrix.tag_prefix }} | |
| overwrite: true | |
| body: "containerd image for ${{ matrix.tag_prefix }} (amd64 + arm64)" | |
| - name: Push multi-arch image to GHCR | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: dockerfiles/ | |
| file: dockerfiles/${{ matrix.dockerfile }} | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository_owner }}/${{ matrix.tag_prefix }}:latest |