v1.5.2 #121
Workflow file for this run
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: Publish Docker Images | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| release: | |
| types: | |
| - published | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| platform: [linux/amd64, linux/arm64] | |
| runner: [ubuntu-24.04] | |
| exclude: | |
| - platform: linux/arm64 | |
| runner: ubuntu-24.04 | |
| include: | |
| - platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| fetch-tags: true | |
| - name: Platform env | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "PLATFORM_ARCH=${platform//\//-}" >> $GITHUB_ENV | |
| - name: Get version tag | |
| run: | | |
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "latest") | |
| echo "TAG=$LAST_TAG" >> $GITHUB_ENV | |
| else | |
| echo "TAG=latest" >> $GITHUB_ENV | |
| fi | |
| - 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.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get build timestamp | |
| run: | | |
| if [[ -n "${{ github.event.head_commit.timestamp }}" ]]; then | |
| echo "BUILD_TIMESTAMP=${{ github.event.head_commit.timestamp }}" >> $GITHUB_ENV | |
| elif [[ -n "${{ github.event.created_at }}" ]]; then | |
| echo "BUILD_TIMESTAMP=${{ github.event.created_at }}" >> $GITHUB_ENV | |
| else | |
| echo "BUILD_TIMESTAMP=$(git log -1 --format=%cI)" >> $GITHUB_ENV | |
| fi | |
| - name: Build and push Docker image | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| platforms: ${{ matrix.platform }} | |
| context: . | |
| labels: | | |
| org.opencontainers.image.version=${{ env.TAG }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| org.opencontainers.image.created=${{ env.BUILD_TIMESTAMP }} | |
| org.opencontainers.image.source="https://github.com/rhee876527/chiyogami" | |
| org.opencontainers.image.authors="Martin Kibera" | |
| org.opencontainers.image.vendor="Martin Kibera" | |
| org.opencontainers.image.licenses="BSD 3-Clause" | |
| org.opencontainers.image.title="Chiyogami" | |
| outputs: type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ env.PLATFORM_ARCH }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge: | |
| runs-on: ubuntu-24.04 | |
| needs: build | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: digests-* | |
| merge-multiple: true | |
| - 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.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| fetch-tags: true | |
| - name: Get version tag | |
| run: | | |
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
| elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "latest") | |
| echo "TAG=$LAST_TAG" >> $GITHUB_ENV | |
| else | |
| echo "TAG=latest" >> $GITHUB_ENV | |
| fi | |
| - name: Create manifest list and push | |
| run: | | |
| IMAGES="" | |
| for digest in /tmp/digests/*; do | |
| IMAGES+="ghcr.io/${{ github.repository }}@sha256:$(basename "$digest") " | |
| done | |
| docker buildx imagetools create \ | |
| -t ghcr.io/${{ github.repository }}:latest \ | |
| -t ghcr.io/${{ github.repository }}:${{ env.TAG }} \ | |
| $IMAGES | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ghcr.io/${{ github.repository }}:latest | |
| docker buildx imagetools inspect ghcr.io/${{ github.repository }}:${{ env.TAG }} |