|
| 1 | +name: "Publish must-gather image" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + tags: [ 'v*' ] |
| 7 | + |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + PLATFORMS: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le |
| 12 | + |
| 13 | +jobs: |
| 14 | + publish: |
| 15 | + name: Publish must-gather container image |
| 16 | + runs-on: ubuntu-22.04 |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - uses: actions/setup-go@v5 |
| 21 | + with: |
| 22 | + go-version: '~1.22.4' |
| 23 | + |
| 24 | + - name: Unshallow |
| 25 | + run: git fetch --prune --unshallow |
| 26 | + |
| 27 | + - name: Build the binary for each supported architecture |
| 28 | + run: | |
| 29 | + for platform in $(echo $PLATFORMS | tr "," "\n"); do |
| 30 | + arch=${platform#*/} |
| 31 | + echo "Building must-gather for $arch" |
| 32 | + make must-gather ARCH=$arch |
| 33 | + done |
| 34 | +
|
| 35 | + - name: Docker meta |
| 36 | + id: docker_meta |
| 37 | + uses: docker/metadata-action@v5 |
| 38 | + with: |
| 39 | + images: | |
| 40 | + ghcr.io/open-telemetry/opentelemetry-operator/must-gather |
| 41 | + tags: | |
| 42 | + type=semver,pattern={{version}} |
| 43 | + type=semver,pattern={{major}}.{{minor}} |
| 44 | + type=semver,pattern={{raw}} |
| 45 | + type=ref,event=branch |
| 46 | +
|
| 47 | + - name: Set up QEMU |
| 48 | + uses: docker/setup-qemu-action@v3 |
| 49 | + |
| 50 | + - name: Set up Docker Buildx |
| 51 | + uses: docker/setup-buildx-action@v3 |
| 52 | + |
| 53 | + - name: Cache Docker layers |
| 54 | + uses: actions/cache@v4 |
| 55 | + with: |
| 56 | + path: /tmp/.buildx-cache |
| 57 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 58 | + restore-keys: | |
| 59 | + ${{ runner.os }}-buildx- |
| 60 | +
|
| 61 | + - name: Log into Docker.io |
| 62 | + uses: docker/login-action@v3 |
| 63 | + if: ${{ github.event_name == 'push' }} |
| 64 | + with: |
| 65 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 66 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 67 | + |
| 68 | + - name: Login to GitHub Package Registry |
| 69 | + uses: docker/login-action@v3 |
| 70 | + if: ${{ github.event_name == 'push' }} |
| 71 | + with: |
| 72 | + registry: ghcr.io |
| 73 | + username: ${{ github.repository_owner }} |
| 74 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + |
| 76 | + - name: Build and push must-gather image |
| 77 | + uses: docker/build-push-action@v6 |
| 78 | + with: |
| 79 | + context: . |
| 80 | + file: ./cmd/gather/Dockerfile |
| 81 | + platforms: ${{ env.PLATFORMS }} |
| 82 | + push: ${{ github.event_name != 'pull_request' }} |
| 83 | + tags: ${{ steps.docker_meta.outputs.tags }} |
| 84 | + labels: ${{ steps.docker_meta.outputs.labels }} |
| 85 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 86 | + cache-to: type=local,dest=/tmp/.buildx-cache |
0 commit comments