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

Fix start new PR with own repo #34

Merged
merged 1 commit into from Apr 3, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 17 additions & 13 deletions .github/workflows/example-fix.yaml
@@ -1,5 +1,8 @@
name: Suggest autofixes with Kubescape
on: [push, pull_request_target]
on:
push:
branches: [ main ]
pull_request_target:

jobs:
kubescape-fix:
Expand All @@ -25,6 +28,7 @@ jobs:
uses: tj-actions/changed-files@v35
- uses: kubescape/github-action@main
with:
account: ${{secrets.KUBESCAPE_ACCOUNT}}
files: ${{ steps.changed-files.outputs.all_changed_files }}
fixFiles: true
format: "sarif"
Expand All @@ -46,21 +50,21 @@ jobs:
base: ${{ github.head_ref }}
branch: kubescape-auto-fix-${{ github.head_ref || github.ref_name }}
delete-branch: true
# # Alternatively, you can use reviewdog to replace the code-suggester
# # Alternatively, you can use googleapis/code-suggester to replace the reviewdog below
# - name: Clean up kubescape output
# if: github.event_name == 'pull_request_target'
# run: rm -f results.json results.sarif
# - name: PR Suggester
# if: github.event_name == 'pull_request_target'
# uses: reviewdog/action-suggester@v1
# uses: googleapis/code-suggester@v2
# env:
# ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tool_name: Kubescape
- name: Clean up kubescape output
if: github.event_name == 'pull_request_target'
run: rm results.json results.sarif
# command: review
# pull_number: ${{ github.event.pull_request.number }}
# git_dir: '.'
- name: PR Suggester
if: github.event_name == 'pull_request_target'
uses: googleapis/code-suggester@v2
env:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: reviewdog/action-suggester@v1
with:
command: review
pull_number: ${{ github.event.pull_request.number }}
git_dir: '.'
tool_name: Kubescape
33 changes: 18 additions & 15 deletions README.md
Expand Up @@ -39,14 +39,17 @@ You can then see the results in the Pull Request that triggered the scan and the

### Automatically Suggest Fixes

To make Kubescape automatically suggest fixes to your pushes (by opening new PRs) and pull requests (by code review), use the following workflow:
To make Kubescape automatically suggest fixes to your pushes to your main branch (by opening new PRs) and pull requests (by code review), use the following workflow:

```yaml
name: Suggest autofixes with Kubescape
on: [push, pull_request_target]
on:
push:
branches: [ main ]
pull_request_target:

jobs:
kubescape:
kubescape-fix:
runs-on: ubuntu-latest
permissions:
# Needed only for "push" events
Expand Down Expand Up @@ -91,24 +94,24 @@ jobs:
base: ${{ github.head_ref }}
branch: kubescape-auto-fix-${{ github.head_ref || github.ref_name }}
delete-branch: true
# # Alternatively, you can use reviewdog to replace the code-suggester below
# # Alternatively, you can use googleapis/code-suggester to replace the reviewdog below
# - name: Clean up kubescape output
# if: github.event_name == 'pull_request_target'
# run: rm -f results.json results.sarif
# - name: PR Suggester
# if: github.event_name == 'pull_request_target'
# uses: reviewdog/action-suggester@v1
# uses: googleapis/code-suggester@v2
# env:
# ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tool_name: Kubescape
- name: Clean up kubescape output
if: github.event_name == 'pull_request_target'
run: rm -f results.json results.sarif
# command: review
# pull_number: ${{ github.event.pull_request.number }}
# git_dir: '.'
- name: PR Suggester
if: github.event_name == 'pull_request_target'
uses: googleapis/code-suggester@v2
env:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: reviewdog/action-suggester@v1
with:
command: review
pull_number: ${{ github.event.pull_request.number }}
git_dir: '.'
tool_name: Kubescape
```

Please note that since Kubescape provides automatic fixes only to the rendered YAML manifests, the workflow above will not produce correct fixes for Helm charts.
Expand Down