Publish Chatwoot Enterprise docker images to GitHub #79
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 Chatwoot Enterprise docker images to GitHub | |
| permissions: | |
| contents: read | |
| packages: write | |
| on: | |
| release: | |
| types: [released] | |
| workflow_dispatch: | |
| env: | |
| GITHUB_REPO: ghcr.io/${{ github.repository }} | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| runner: blacksmith-4vcpu-ubuntu-2404 | |
| - platform: linux/arm64 | |
| runner: blacksmith-4vcpu-ubuntu-2404 | |
| runs-on: ${{ matrix.runner }} | |
| env: | |
| GIT_REF: ${{ github.event.release.tag_name || github.ref_name }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.release.tag_name || github.ref }} | |
| - name: Prepare | |
| run: | | |
| platform=${{ matrix.platform }} | |
| echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
| - name: Set Chatwoot edition | |
| run: | | |
| echo -en '\nENV CW_EDITION="ee"' >> docker/Dockerfile | |
| - name: Update version in app.yml | |
| run: | | |
| if [[ "$GIT_REF" =~ ^v(.+)$ ]]; then | |
| VERSION="${BASH_REMATCH[1]}" | |
| echo "Updating version to: $VERSION" | |
| sed -i "s/version: '.*'/version: '$VERSION'/" config/app.yml | |
| else | |
| echo "No version tag found, keeping existing version" | |
| fi | |
| - name: Set Docker Tags | |
| run: | | |
| SANITIZED_REF=$(echo "$GIT_REF" | sed 's/\//-/g') | |
| echo "SANITIZED_REF=${SANITIZED_REF}" >> $GITHUB_ENV | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Setup Blacksmith Builder | |
| uses: useblacksmith/setup-docker-builder@v1 | |
| - name: Login to GitHub Container Registry | |
| if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push to GitHub Container Registry | |
| id: build-ghcr | |
| uses: useblacksmith/build-push-action@v2 | |
| with: | |
| context: . | |
| file: docker/Dockerfile | |
| platforms: ${{ matrix.platform }} | |
| push: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }} | |
| tags: | | |
| ${{ env.GITHUB_REPO }}:${{ env.SANITIZED_REF }} | |
| ${{ env.GITHUB_REPO }}:latest | |
| - name: Export digest | |
| run: | | |
| mkdir -p ${{ runner.temp }}/digests | |
| digest="${{ steps.build-ghcr.outputs.digest }}" | |
| touch "${{ runner.temp }}/digests/${digest#sha256:}" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ env.PLATFORM_PAIR }} | |
| path: ${{ runner.temp }}/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge: | |
| runs-on: blacksmith-4vcpu-ubuntu-2404 | |
| needs: | |
| - build | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ${{ runner.temp }}/digests | |
| pattern: digests-* | |
| merge-multiple: true | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Blacksmith Builder | |
| uses: useblacksmith/setup-docker-builder@v1 | |
| - name: Create manifest list and push | |
| working-directory: ${{ runner.temp }}/digests | |
| env: | |
| GIT_REF: ${{ github.event.release.tag_name || github.ref_name }} | |
| run: | | |
| SANITIZED_REF=$(echo "$GIT_REF" | sed 's/\//-/g') | |
| docker buildx imagetools create \ | |
| -t ghcr.io/${{ github.repository }}:${SANITIZED_REF} \ | |
| -t ghcr.io/${{ github.repository }}:latest \ | |
| $(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *) | |
| - name: Inspect image | |
| env: | |
| GIT_REF: ${{ github.event.release.tag_name || github.ref_name }} | |
| run: | | |
| SANITIZED_REF=$(echo "$GIT_REF" | sed 's/\//-/g') | |
| REPO="ghcr.io/${{ github.repository }}" | |
| docker buildx imagetools inspect ${REPO}:${SANITIZED_REF} | |
| docker buildx imagetools inspect ${REPO}:latest |