|
| 1 | +name: Build and publish a Smee client container image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - containers/Dockerfile.smee-client |
| 7 | + - .github/workflows/build_smee_client_container_image.yaml |
| 8 | + pull_request: |
| 9 | + paths: |
| 10 | + - containers/Dockerfile.smee-client |
| 11 | + - .github/workflows/build_smee_client_container_image.yaml |
| 12 | + |
| 13 | +# Declare default permissions as read only. |
| 14 | +permissions: read-all |
| 15 | + |
| 16 | +jobs: |
| 17 | + docker_build_smee_client: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + packages: write |
| 21 | + steps: |
| 22 | + - name: Check out the repo |
| 23 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 24 | + |
| 25 | + - name: Login to GitHub Container Registry |
| 26 | + if: github.event_name != 'pull_request' |
| 27 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 |
| 28 | + with: |
| 29 | + registry: ghcr.io |
| 30 | + username: ${{ github.repository_owner }} |
| 31 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Convert and store repository owner in lowercase, replace colon in tag names by hyphen |
| 34 | + run: | |
| 35 | + echo REPOSITORY_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV |
| 36 | +
|
| 37 | + - name: Set up QEMU |
| 38 | + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 |
| 39 | + |
| 40 | + - name: Set up Docker Buildx |
| 41 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 |
| 42 | + |
| 43 | + - name: Cache Docker layers |
| 44 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 |
| 45 | + with: |
| 46 | + path: ${{ runner.temp }}/.buildx-cache |
| 47 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 48 | + restore-keys: | |
| 49 | + ${{ runner.os }}-buildx- |
| 50 | +
|
| 51 | + - name: Build and push |
| 52 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 |
| 53 | + with: |
| 54 | + tags: ghcr.io/${{ env.REPOSITORY_OWNER }}/smee-client |
| 55 | + platforms: linux/amd64,linux/arm64 |
| 56 | + push: ${{ github.event_name != 'pull_request' }} # don't publish if this is part of an open PR |
| 57 | + file: containers/Dockerfile.smee-client |
| 58 | + cache-from: type=local,src=${{ runner.temp }}/.buildx-cache |
| 59 | + cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max |
| 60 | + |
| 61 | + - name: Move cache |
| 62 | + run: | |
| 63 | + rm -rf ${{ runner.temp }}/.buildx-cache |
| 64 | + mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache |
0 commit comments