diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..b8b6ffd --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,44 @@ +name: Generate Changelog +run-name: Generate Changelog ${{ github.sha }} by @${{ github.actor }} + +on: + workflow_dispatch: + workflow_run: + workflows: [Release] + types: [completed] + branches: [main] + +jobs: + changelog: + name: Generate Changelog + runs-on: ubuntu-latest + permissions: + contents: write # to be able to commit changes + pull-requests: write # to be able to create pull requests + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: 0 + - name: Generate Changelog + uses: orhun/git-cliff-action@cb015de125f15039c823b8be209c632aa436c76c # v3.3.0 + id: git-cliff + with: + args: -vv --latest --prepend CHANGELOG.md --no-exec # https://git-cliff.org/docs/usage/args + env: + GITHUB_REPO: ${{ github.repository }} + - name: Get Release Version + run: echo "RELEASE_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV + - name: Create Pull Request + uses: peter-evans/create-pull-request@ba864ad40c29a20a464f75f942160a3213edfbd1 # v6.1.0 + with: + add-paths: CHANGELOG.md + commit-message: "chore(release): update changelog after ${{ env.RELEASE_TAG }}" + title: "chore(release): update changelog" + body: | + :robot: Update changelog after the release of [${{ env.RELEASE_TAG }}](https://github.com/${{ github.repository }}/releases/tag/${{ env.RELEASE_TAG }}) +
Changelog Details + + ${{ steps.git-cliff.outputs.content }} +
+ branch: "chore/update-changelog" + base: main diff --git a/.github/workflows/ci-terraform.yml b/.github/workflows/ci-terraform.yml new file mode 100644 index 0000000..b93c15b --- /dev/null +++ b/.github/workflows/ci-terraform.yml @@ -0,0 +1,86 @@ +name: Terraform CI +run-name: Terraform CI by @${{ github.actor }} ${{ github.sha }} + +on: + push: + branches: + - main + paths: + - "**.tf" + - "!examples/**" + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + terraform-ci: + permissions: + pull-requests: write + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')" + defaults: + run: + working-directory: ${{ env.tf_actions_working_dir }} + steps: + - uses: actions/checkout@v4 + - uses: hashicorp/setup-terraform@v3 + + - name: Terraform fmt + id: fmt + run: terraform fmt -check + continue-on-error: true + + - name: Terraform Init + id: init + run: terraform init + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + + - uses: actions/github-script@v7 + if: github.event_name == 'pull_request' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + // 1. Retrieve existing bot comments for the PR + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }) + const botComment = comments.find(comment => { + return comment.user.type === 'Bot' && comment.body.includes('Terraform Format and Style') + }) + + // 2. Prepare format of the comment + const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\` + #### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` + #### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` +
Validation Output + + \`\`\`\n + ${{ steps.validate.outputs.stdout }} + \`\`\` + +
+ + *Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; + + // 3. If we have a comment, update it, otherwise create a new one + if (botComment) { + github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: botComment.id, + body: output + }) + } else { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: output + }) + } diff --git a/.github/workflows/markdownlint.yml b/.github/workflows/markdownlint.yml new file mode 100644 index 0000000..b2f8bea --- /dev/null +++ b/.github/workflows/markdownlint.yml @@ -0,0 +1,29 @@ +name: Markdown Lint +run-name: Markdown Lint ${{ github.sha }} by @${{ github.actor }} + +on: + pull_request: + types: [opened, synchronize, reopened] + paths: + - "**/*.md" + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: 0 + - name: Get changed files + uses: tj-actions/changed-files@48d8f15b2aaa3d255ca5af3eba4870f807ce6b3c # v45.0.2 + id: changed-files + with: + files: "**/*.md" + separator: "," + - name: Run markdownlint + uses: DavidAnson/markdownlint-cli2-action@db43aef879112c3119a410d69f66701e0d530809 # v17.0.0 + if: steps.changed-files.outputs.any_changed == 'true' + with: + globs: ${{ steps.changed-files.outputs.all_changed_files }} + separator: "," diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2302d8f..42c068a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: - name: Set up Auto uses: auto-it/setup-auto@v1 with: - gh-token: ${{ secrets.GH_TOKEN }} + gh-token: ${{ secrets.GITHUB_TOKEN }} - name: Release run: auto shipit diff --git a/.github/workflows/semantic-pr-title.yml b/.github/workflows/semantic-pr-title.yml new file mode 100644 index 0000000..cc9285d --- /dev/null +++ b/.github/workflows/semantic-pr-title.yml @@ -0,0 +1,19 @@ +name: Validate PR Title +run-name: Validate PR Title ${{ github.sha }} by @${{ github.actor }} + +on: + merge_group: + pull_request: + types: [opened, edited, synchronize, reopened] + +permissions: + pull-requests: read + +jobs: + main: + name: Semantic PR Title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/trufflehog.yml b/.github/workflows/trufflehog.yml new file mode 100644 index 0000000..be94ff8 --- /dev/null +++ b/.github/workflows/trufflehog.yml @@ -0,0 +1,20 @@ +name: Secrets Detection +run-name: Secrets Detection ${{ github.sha }} by @${{ github.actor }} + +on: + merge_group: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + scan: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: 0 + - name: Secret Scanning + uses: trufflesecurity/trufflehog@7e78ca385fb82c19568c7a4b341c97d57d9aa5e1 # v3.82.2 + with: + extra_args: --only-verified