Skip to content

Commit

Permalink
ci: update and add new workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
dstrates committed Dec 14, 2024
1 parent 561ba11 commit 1dd6209
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 1 deletion.
44 changes: 44 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -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 }})
<details><summary>Changelog Details</summary>
${{ steps.git-cliff.outputs.content }}
</details>
branch: "chore/update-changelog"
base: main
86 changes: 86 additions & 0 deletions .github/workflows/ci-terraform.yml
Original file line number Diff line number Diff line change
@@ -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 }}\`
<details><summary>Validation Output</summary>
\`\`\`\n
${{ steps.validate.outputs.stdout }}
\`\`\`
</details>
*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
})
}
29 changes: 29 additions & 0 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
@@ -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: ","
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions .github/workflows/semantic-pr-title.yml
Original file line number Diff line number Diff line change
@@ -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 }}
20 changes: 20 additions & 0 deletions .github/workflows/trufflehog.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1dd6209

Please sign in to comment.