Fix CI/CD structure #63
This file contains 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
name: CI/CD Pipeline | |
permissions: | |
contents: read | |
security-events: write | |
on: | |
push: | |
pull_request: | |
branches: | |
- main | |
types: [opened, synchronize, reopened] | |
jobs: | |
get-metadata: | |
name: "Get Metadata" | |
runs-on: ubuntu-latest | |
outputs: | |
build_datetime: ${{ steps.metadata.outputs.build_datetime }} | |
build_timestamp: ${{ steps.metadata.outputs.build_timestamp }} | |
build_epoch: ${{ steps.metadata.outputs.build_epoch }} | |
steps: | |
- id: metadata | |
run: | | |
datetime=$(date -u +'%Y-%m-%dT%H:%M:%S%z') | |
echo "build_datetime=$datetime" >> $GITHUB_OUTPUT | |
echo "build_timestamp=$(date --date=$datetime -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT | |
echo "build_epoch=$(date --date=$datetime -u +'%s')" >> $GITHUB_OUTPUT | |
scan-secrets: | |
needs: [get-metadata] | |
runs-on: ubuntu-latest | |
name: "Secrets Scan" | |
steps: | |
- uses: ./.github/actions/scan-secrets/ | |
check-format: | |
needs: [get-metadata] | |
runs-on: ubuntu-latest | |
name: Check File & Markdown Format | |
steps: | |
- uses: ./.github/actions/check-format/ | |
checkov: | |
name: Checkov | |
runs-on: ubuntu-latest | |
needs: [scan-secrets, check-format] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install Latest Checkov | |
id: install-checkov | |
run: pip install --user checkov | |
- name: Run Checkov | |
id: run-checkov | |
run: checkov --directory . -o sarif -s --quiet | |
- name: Upload SARIF File | |
uses: github/codeql-action/upload-sarif@v2 | |
if: always() && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
with: | |
sarif_file: results.sarif | |
tflint: | |
name: TFLint | |
runs-on: ubuntu-latest | |
needs: [scan-secrets, check-format] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup TFLint Cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.tflint.d/plugins | |
key: tflint-${{ hashFiles('.tflint.hcl') }} | |
- name: Setup TFLint | |
uses: terraform-linters/setup-tflint@v3 | |
with: | |
tflint_version: v0.47.0 | |
- name: Init TFLint | |
run: tflint --init | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Run TFLint | |
run: tflint -f compact |