Skip to content
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

k8s image content from PRs: fix execution and add instruction how to use the image #11459

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions .github/workflows/k8s-content-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: unzip pr_number.zip
- name: 'Read PR number'
run: |
echo "pr-number=$(cat pr/pr_number)" >> "$GITHUB_OUTPUT"
echo "pr-number=$(cat pr_number)" >> "$GITHUB_OUTPUT"

container-main:
needs:
Expand Down Expand Up @@ -101,16 +101,24 @@ jobs:
- container-main
- get-pr-number
runs-on: ubuntu-latest
name: Comment on the PR
name: Upsert comment on the PR
steps:
- uses: actions/github-script@v7
- uses: thollander/actions-comment-pull-request@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ needs.get-pr-number.outputs.pr-number }},
body: ':robot: The image for this PR is available at:
`ghcr.io/complianceascode/k8scontent:${{ needs.get-pr-number.outputs.pr-number }}`'
});
message: |
:robot: A k8s content image for this PR is available at:
`ghcr.io/complianceascode/k8scontent:${{ needs.get-pr-number.outputs.pr-number }}`

<details>
<summary>Click here to see how to deploy it</summary>

If you alread have Compliance Operator deployed:
```utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:${{ needs.get-pr-number.outputs.pr-number }}```
rhmdnd marked this conversation as resolved.
Show resolved Hide resolved

Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and:
```CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:${{ needs.get-pr-number.outputs.pr-number }} make deploy-local```

</details>
comment_tag: kubernetes_content_image
pr_number: ${{ needs.get-pr-number.outputs.pr-number }}
9 changes: 9 additions & 0 deletions utils/build_ds_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
'--product and --debug flags.'),
action='store_true',
default=False)
parser.add_argument(
'-i', '--push-content-image',
help=(
'Do not build any content. Create profile bundles from the referenced k8s content image'),
rhmdnd marked this conversation as resolved.
Show resolved Hide resolved
)
parser.add_argument(
'-d', '--debug',
help=(
Expand Down Expand Up @@ -270,6 +275,10 @@ def get_image_repository():
return image_repo.decode().strip()


if args.push_content_image:
create_profile_bundles(args.products, args.push_content_image)
sys.exit(0)

log.info(f'Building content for {", ".join(args.products)}')
ensure_namespace_exists()

Expand Down
Loading