-
Notifications
You must be signed in to change notification settings - Fork 0
ci: Rework workflows to decrease duplication and improve maintainability. #35
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
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,53 @@ | ||
| name: Discover changed OpenTofu modules | ||
| description: | | ||
| Finds all OpenTofu modules that have changed in a pull request or push to a | ||
| branch. | ||
| outputs: | ||
| modules: | ||
| description: A JSON array of all changed modules. | ||
| value: ${{ steps.modified.outputs.modules }} | ||
| inputs: | ||
| working-directory: | ||
| description: The working directory to search for modules in. | ||
| required: false | ||
| default: tofu | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Find all OpenTofu modules | ||
| id: find | ||
| uses: bendrucker/find-terraform-modules@v1 | ||
| with: | ||
| working-directory: ${{ inputs.working-directory }} | ||
| - name: Show all matching modules | ||
| shell: bash | ||
| run: | | ||
| mods=(${{ join(fromJSON(steps.find.outputs.modules), ' ') }}) | ||
| printf "%s\n" "${mods[@]}" | ||
| - name: Find all changed files | ||
| id: diff | ||
| uses: technote-space/get-diff-action@v6 | ||
| with: | ||
| FORMAT: json | ||
| - name: Show changed files | ||
| shell: bash | ||
| run: | | ||
| echo "${{ steps.diff.outputs.diff }}" | ||
| - name: Get the modified modules | ||
| id: modified | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const modules = ${{ steps.find.outputs.modules }} | ||
| const diff = ${{ steps.diff.outputs.diff }} | ||
| const modifiedModules = modules.filter( | ||
| (module) => { | ||
| return !!diff.find(file => new RegExp(`^${module}/.+`).test(file)) | ||
| } | ||
| ) | ||
|
|
||
| core.setOutput('modules', modifiedModules) | ||
| - name: Show modified modules | ||
| shell: bash | ||
| run: | | ||
| echo "${{ steps.modified.outputs.modules }}" |
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,29 @@ | ||
| name: Check for GitHub security features | ||
| description: | | ||
| Checks if the repository is public or has GitHub Advanced Security enabled. | ||
| outputs: | ||
| codeql: | ||
| description: Whether or not CodeQL analysis is supported. | ||
| value: ${{ github.event.repository.security_and_analysis.advanced_security_enabled || !github.event.repository.private }} | ||
| ghas: | ||
| description: Whether or not GitHub Advanced Security is enabled. | ||
| value: ${{ github.event.repository.security_and_analysis.advanced_security_enabled }} | ||
| public: | ||
| description: Whether or not the repository is public. | ||
| value: ${{ github.event.repository.private == false }} | ||
| sarif: | ||
| description: Whether or not SARIF uploads are supported. | ||
| value: ${{ github.event.repository.security_and_analysis.advanced_security_enabled || !github.event.repository.private }} | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: GHAS enabled notice | ||
| shell: bash | ||
| if: ${{ github.event.repository.security_and_analysis.advanced_security_enabled }} | ||
| run: | | ||
| echo "GitHub Advanced Security is enabled." | ||
| - name: Public repository notice | ||
| shell: bash | ||
| if: ${{ github.event.repository.private == false }} | ||
| run: | | ||
| echo "Repository is public." |
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
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,46 @@ | ||
| name: TFLint Checks | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@v4 | ||
| - name: Check security features | ||
| id: security-features | ||
| uses: ./.github/actions/security-features | ||
| - name: Cache plugin directory | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.tflint.d/plugins | ||
| key: tflint-${{ hashFiles('.tflint.hcl') }} | ||
| - uses: terraform-linters/setup-tflint@v5 | ||
| name: Setup TFLint | ||
| - name: Show version | ||
| run: tflint --version | ||
| - name: Init TFLint | ||
| run: tflint --init | ||
| - name: Run TFLint | ||
| run: tflint --format sarif --recursive --config "$GITHUB_WORKSPACE/.tflint.hcl" > tflint-results.sarif | ||
| - name: Parse SARIF file for annotations | ||
| if: always() | ||
| uses: Miragon/[email protected] | ||
| with: | ||
| severity-level: low | ||
| sarif-file: tflint-results.sarif | ||
| # When run on main, if SARIF uploads are available, we want to upload the | ||
| # SARIF file to GitHub. | ||
| - name: Upload SARIF result | ||
| if: always() && github.ref == 'refs/heads/main' && steps.security-features.outputs.sarif == 'true' | ||
| uses: github/codeql-action/upload-sarif@v3 | ||
| with: | ||
| sarif_file: tflint-results.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,39 @@ | ||
| name: Trivy Analysis | ||
|
|
||
| on: | ||
| push: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| trivy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@v4 | ||
| - name: Check security features | ||
| id: security-features | ||
| uses: ./.github/actions/security-features | ||
| - name: Run Trivy vulnerability scanner | ||
| uses: aquasecurity/[email protected] | ||
| with: | ||
| scan-type: config | ||
| ignore-unfixed: true | ||
| skip-dirs: "**/*/.terraform" | ||
| exit-code: 1 | ||
| format: sarif | ||
| output: trivy-results.sarif | ||
| - name: Parse SARIF file for annotations | ||
| if: always() | ||
| uses: Miragon/[email protected] | ||
| with: | ||
| severity-level: low | ||
| sarif-file: trivy-results.sarif | ||
| # When run on main, if SARIF uploads are available, we want to upload the | ||
| # SARIF file to GitHub. | ||
| - name: Upload SARIF result | ||
| if: always() && github.ref == 'refs/heads/main' && steps.security-features.outputs.sarif == 'true' | ||
| uses: github/codeql-action/upload-sarif@v3 | ||
| with: | ||
| sarif_file: trivy-results.sarif | ||
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.