forked from 28mm/blast-radius
-
Notifications
You must be signed in to change notification settings - Fork 12
add hadolint support #48
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
Open
Jubblin
wants to merge
9
commits into
Ianyliu:main
Choose a base branch
from
Jubblin:Jubblin-patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c330853
Create docker-publish.yml
Jubblin 3e3d424
Update docker-publish.yml
Jubblin cbc6fcd
Update docker-publish.yml
Jubblin 6635436
Update docker-publish.yml
Jubblin f5d88f9
Update docker-publish.yml
Jubblin 78561f8
Create container-publish.yml
Jubblin 7cd0531
Delete .github/workflows/docker-publish.yml
Jubblin b42f52a
Update container-publish.yml
Jubblin a74a439
Create container-best-practices.yml
Jubblin 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| name: Container Best Practices | ||
|
|
||
| on: | ||
| pull_request: | ||
|
|
||
| env: | ||
| # Use docker.io for Docker Hub if empty | ||
| REGISTRY: ghcr.io | ||
| # github.repository as <account>/<repo> | ||
| IMAGE_NAME: ${{ github.repository }} | ||
|
|
||
| jobs: | ||
| lint: | ||
| # The type of runner that the job will run on | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read # for actions/checkout to fetch code | ||
| security-events: write # for github/codeql-action/upload-sarif to upload SARIF results | ||
| actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Lint Dockerfile | ||
| if: github.event_name != 'pull_request' | ||
| uses: hadolint/[email protected] | ||
| with: | ||
| dockerfile: Dockerfile | ||
| no-fail: true | ||
| format: sarif | ||
| output-file: hadolint.sarif | ||
|
|
||
| - name: Update Pull Request | ||
| uses: actions/github-script@v6 | ||
| if: github.event_name == 'pull_request' | ||
| with: | ||
| script: | | ||
| const output = ` | ||
| #### Hadolint: \`${{ steps.hadolint.outcome }}\` | ||
| \`\`\` | ||
| ${process.env.HADOLINT_RESULTS} | ||
| \`\`\` | ||
| `; | ||
|
|
||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: output | ||
| }) | ||
| - name: Upload SARIF file | ||
| uses: github/codeql-action/upload-sarif@v2 | ||
| if: success() || failure() | ||
| with: | ||
| sarif_file: hadolint.sarif | ||
|
|
||
| scan: | ||
| # The type of runner that the job will run on | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read # for actions/checkout to fetch code | ||
| security-events: write # for github/codeql-action/upload-sarif to upload SARIF results | ||
| actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status | ||
|
|
||
| # Steps represent a sequence of tasks that will be executed as part of the job | ||
| steps: | ||
| # Checks-out your repository under $GITHUB_WORKSPACE, so follow-up steps can access it | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Checkov GitHub Action | ||
| uses: bridgecrewio/checkov-action@v12 | ||
| with: | ||
| # This will add both a CLI output to the console and create a results.sarif file | ||
| output_format: cli,sarif | ||
| output_file_path: console,checkov.sarif | ||
|
|
||
| - name: Upload SARIF file | ||
| uses: github/codeql-action/upload-sarif@v2 | ||
|
|
||
| # Results are generated only on a success or failure | ||
| # this is required since GitHub by default won't run the next step | ||
| # when the previous one has failed. Security checks that do not pass will 'fail'. | ||
| # An alternative is to add `continue-on-error: true` to the previous step | ||
| # Or 'soft_fail: true' to checkov. | ||
| if: success() || failure() | ||
| with: | ||
| sarif_file: checkov.sarif | ||
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,122 @@ | ||
| name: Docker | ||
|
|
||
| # This workflow uses actions that are not certified by GitHub. | ||
| # They are provided by a third-party and are governed by | ||
| # separate terms of service, privacy policy, and support | ||
| # documentation. | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| # Publish semver tags as releases. | ||
| tags: [ 'v*.*.*' ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
||
| env: | ||
| # Use docker.io for Docker Hub if empty | ||
| REGISTRY: ghcr.io | ||
| # github.repository as <account>/<repo> | ||
| IMAGE_NAME: ${{ github.repository }} | ||
|
|
||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
Comment on lines
+27
to
+28
Check failureCode scanning / checkov Ensure top-level permissions are not set to write-all
Ensure top-level permissions are not set to write-all
|
||
| packages: write | ||
| # This is used to complete the identity challenge | ||
| # with sigstore/fulcio when running outside of PRs. | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Lint Dockerfile | ||
| if: github.event_name != 'pull_request' | ||
| uses: hadolint/[email protected] | ||
| with: | ||
| dockerfile: Dockerfile | ||
|
|
||
| - name: Update Pull Request | ||
| uses: actions/github-script@v6 | ||
| if: github.event_name == 'pull_request' | ||
| with: | ||
| script: | | ||
| const output = ` | ||
| #### Hadolint: \`${{ steps.hadolint.outcome }}\` | ||
| \`\`\` | ||
| ${process.env.HADOLINT_RESULTS} | ||
| \`\`\` | ||
| `; | ||
|
|
||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: output | ||
| }) | ||
|
|
||
| # Install the cosign tool except on PR | ||
| # https://github.com/sigstore/cosign-installer | ||
| - name: Install cosign | ||
| if: github.event_name != 'pull_request' | ||
| uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0 | ||
| with: | ||
| cosign-release: 'v2.2.4' | ||
|
|
||
| # Set up BuildKit Docker container builder to be able to build | ||
| # multi-platform images and export cache | ||
| # https://github.com/docker/setup-buildx-action | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | ||
|
|
||
| # Login against a Docker registry except on PR | ||
| # https://github.com/docker/login-action | ||
| - name: Log into registry ${{ env.REGISTRY }} | ||
| if: github.event_name != 'pull_request' | ||
| uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| # Extract metadata (tags, labels) for Docker | ||
| # https://github.com/docker/metadata-action | ||
| - name: Extract Docker metadata | ||
| id: meta | ||
| uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
|
||
| # Build and push Docker image with Buildx (don't push on PR) | ||
| # https://github.com/docker/build-push-action | ||
| - name: Build and push Docker image | ||
| id: build-and-push | ||
| uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 | ||
| with: | ||
| platforms: linux/amd64,linux/arm64 | ||
| context: . | ||
| push: ${{ github.event_name != 'pull_request' }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| # Sign the resulting Docker image digest except on PRs. | ||
| # This will only write to the public Rekor transparency log when the Docker | ||
| # repository is public to avoid leaking data. If you would like to publish | ||
| # transparency data even for private images, pass --force to cosign below. | ||
| # https://github.com/sigstore/cosign | ||
| - name: Sign the published Docker image | ||
| if: ${{ github.event_name != 'pull_request' }} | ||
| env: | ||
| # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable | ||
| TAGS: ${{ steps.meta.outputs.tags }} | ||
| DIGEST: ${{ steps.build-and-push.outputs.digest }} | ||
| # This step uses the identity token to provision an ephemeral certificate | ||
| # against the sigstore community Fulcio instance. | ||
| run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} | ||
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.
Check failure
Code scanning / checkov
Ensure top-level permissions are not set to write-all