-
Notifications
You must be signed in to change notification settings - Fork 1
ci: unify PR workflows and fix multiarch images #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
15c1a11
ci: push test image tagged pr-<id> on pull requests
tembleking d02911e
ci: unify PR workflows and fix multi-arch image push
tembleking f45b0be
chore: bump version to 1.0.2
tembleking 28d5a21
ci: push images by digest only, never overwrite :latest
tembleking f3896dd
fix(ci): use Dockerfile with FROM base instead of /dev/null
tembleking 1f51aff
fix(ci): disable provenance attestation to avoid unknown/unknown mani…
tembleking File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| --- | ||
| name: Pull Request CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - master | ||
| workflow_call: | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: "pr-ci-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" | ||
tembleking marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build-and-test: | ||
| name: Build and Test | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| shell: nix develop --command bash {0} | ||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Install Nix | ||
| # Pinned to v21 commit SHA for supply-chain safety. | ||
| # To update: git ls-remote https://github.com/DeterminateSystems/nix-installer-action.git <tag> | ||
| uses: DeterminateSystems/nix-installer-action@c5a866b6ab867e88becbed4467b93592bce69f8a # v21 | ||
|
|
||
| - name: Enable Nix cache | ||
| # Pinned to v13 commit SHA for supply-chain safety. | ||
| # To update: git ls-remote https://github.com/DeterminateSystems/magic-nix-cache-action.git <tag> | ||
| uses: DeterminateSystems/magic-nix-cache-action@565684385bcd71bad329742eefe8d12f2e765b39 # v13 | ||
| with: | ||
| use-flakehub: false | ||
|
|
||
| - name: Build | ||
| run: go build ./... | ||
|
|
||
| - name: Run Checks | ||
| run: just check | ||
| env: | ||
| SYSDIG_MCP_API_HOST: ${{ vars.SYSDIG_MCP_API_HOST }} | ||
| SYSDIG_MCP_API_TOKEN: ${{ secrets.SYSDIG_MCP_API_SECURE_TOKEN }} | ||
|
|
||
| test-image: | ||
| name: Test Image (${{ matrix.arch }}) | ||
| runs-on: ubuntu-latest | ||
| needs: [build-and-test] | ||
| defaults: | ||
| run: | ||
| shell: nix develop --command bash {0} | ||
| permissions: | ||
| contents: read # required for actions/checkout | ||
| packages: write # required for pushing to GHCR | ||
| strategy: | ||
| max-parallel: 1 | ||
| matrix: | ||
| include: | ||
| - arch: amd64 | ||
| platform: linux/amd64 | ||
| nix_package: sysdig-mcp-server-image-amd64 | ||
| - arch: arm64 | ||
| platform: linux/arm64 | ||
| nix_package: sysdig-mcp-server-image-aarch64 | ||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| ref: ${{ github.sha }} | ||
| fetch-depth: "0" | ||
|
|
||
| - name: Install Nix | ||
| # Pinned to v21 commit SHA for supply-chain safety. | ||
| # To update: git ls-remote https://github.com/DeterminateSystems/nix-installer-action.git <tag> | ||
| uses: DeterminateSystems/nix-installer-action@c5a866b6ab867e88becbed4467b93592bce69f8a # v21 | ||
|
|
||
| - name: Enable Nix cache | ||
| # Pinned to v13 commit SHA for supply-chain safety. | ||
| # To update: git ls-remote https://github.com/DeterminateSystems/magic-nix-cache-action.git <tag> | ||
| uses: DeterminateSystems/magic-nix-cache-action@565684385bcd71bad329742eefe8d12f2e765b39 # v13 | ||
| with: | ||
| use-flakehub: false | ||
|
|
||
| - name: Build image | ||
| run: nix build .#${{ matrix.nix_package }} -o result | ||
|
|
||
| - name: Load image | ||
| id: load | ||
| run: | | ||
| IMAGE_TAG=$(docker load < result | sed -n 's/Loaded image: //p') | ||
| echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Test image | ||
| if: matrix.arch == 'amd64' | ||
| run: docker run --rm "${{ steps.load.outputs.image_tag }}" --help | grep "Sysdig MCP Server" | ||
|
|
||
| - name: Scan Docker image | ||
| uses: sysdiglabs/scan-action@v6 | ||
| with: | ||
| image-tag: ${{ steps.load.outputs.image_tag }} | ||
| sysdig-secure-token: ${{ secrets.SECURE_ENV_MON_API_KEY }} | ||
| sysdig-secure-url: ${{ secrets.SECURE_ENV_MON_ENDPOINT }} | ||
| stop-on-failed-policy-eval: true | ||
| stop-on-processing-error: true | ||
tembleking marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Convert to OCI layout | ||
| run: | | ||
| skopeo copy docker-archive:result oci:/tmp/oci-image:latest | ||
| echo "FROM base" > /tmp/Dockerfile.push | ||
tembleking marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Push image by digest | ||
| id: push | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| file: /tmp/Dockerfile.push | ||
| build-contexts: | | ||
| base=oci-layout:///tmp/oci-image | ||
| platforms: ${{ matrix.platform }} | ||
| provenance: false | ||
| outputs: type=image,name=ghcr.io/sysdiglabs/sysdig-mcp-server,push-by-digest=true,name-canonical=true,push=true | ||
|
|
||
| - name: Export digest | ||
| run: | | ||
| mkdir -p /tmp/digests | ||
| digest="${{ steps.push.outputs.digest }}" | ||
| touch "/tmp/digests/${digest#sha256:}" | ||
|
|
||
| - name: Upload digest | ||
| uses: actions/upload-artifact@v5 | ||
| with: | ||
| name: digests-${{ matrix.arch }} | ||
| path: /tmp/digests/* | ||
| if-no-files-found: error | ||
| retention-days: 1 | ||
|
|
||
| push-pr-image: | ||
| name: Push PR image to GitHub Packages | ||
| runs-on: ubuntu-latest | ||
| needs: [test-image] | ||
| if: github.event_name == 'pull_request' | ||
tembleking marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| env: | ||
| REGISTRY: ghcr.io/sysdiglabs/sysdig-mcp-server | ||
| steps: | ||
| - name: Download digests | ||
| uses: actions/download-artifact@v6 | ||
| with: | ||
| path: /tmp/digests | ||
| pattern: digests-* | ||
| merge-multiple: true | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Create manifest list and push | ||
| env: | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| working-directory: /tmp/digests | ||
| run: | | ||
| docker buildx imagetools create --tag $REGISTRY:pr-${PR_NUMBER} \ | ||
| $(printf "$REGISTRY@sha256:%s " *) | ||
|
|
||
| - name: Inspect image | ||
| env: | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| run: docker buildx imagetools inspect $REGISTRY:pr-${PR_NUMBER} | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.