|
| 1 | +name: Publish SDK Utils Container image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'utils/**' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + publish_as_latest: |
| 10 | + description: 'Should this version be tagged as latest?' |
| 11 | + required: false |
| 12 | + type: boolean |
| 13 | + default: false |
| 14 | + workflow_call: |
| 15 | + inputs: |
| 16 | + publish_as_latest: |
| 17 | + description: 'Should this version be tagged as latest?' |
| 18 | + required: false |
| 19 | + type: boolean |
| 20 | + default: false |
| 21 | + |
| 22 | +jobs: |
| 23 | + build-and-push: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + permissions: |
| 26 | + contents: read |
| 27 | + packages: write |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Set up QEMU |
| 34 | + uses: docker/setup-qemu-action@v3 |
| 35 | + |
| 36 | + - name: Set up Docker Buildx |
| 37 | + uses: docker/setup-buildx-action@v3 |
| 38 | + |
| 39 | + - name: Cache Docker layers |
| 40 | + uses: actions/cache@v3 |
| 41 | + with: |
| 42 | + path: /tmp/.buildx-cache |
| 43 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 44 | + restore-keys: | |
| 45 | + ${{ runner.os }}-buildx- |
| 46 | +
|
| 47 | + - name: Login to GitHub Container Registry |
| 48 | + uses: docker/login-action@v3 |
| 49 | + with: |
| 50 | + registry: ghcr.io |
| 51 | + username: ${{ github.actor }} |
| 52 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Build and push |
| 55 | + uses: docker/build-push-action@v6 |
| 56 | + with: |
| 57 | + context: utils |
| 58 | + platforms: linux/amd64,linux/arm64 |
| 59 | + push: true |
| 60 | + tags: | |
| 61 | + ghcr.io/start9labs/start-os/utils:${{ github.sha }} |
| 62 | + ghcr.io/start9labs/start-os/utils:${{ github.run_number }} |
| 63 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 64 | + cache-to: type=local,dest=/tmp/.buildx-cache,new=true |
| 65 | + |
| 66 | + - name: Tag as latest if requested |
| 67 | + if: ${{ inputs.publish_as_latest == 'true' }} |
| 68 | + run: | |
| 69 | + docker tag ghcr.io/start9labs/start-os/utils:${{ github.sha }} ghcr.io/start9labs/start-os/utils:latest |
| 70 | + docker push ghcr.io/start9labs/start-os/utils:latest |
0 commit comments