Skip to content

Commit

Permalink
ci: fix release workflow (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstrates authored Dec 14, 2024
1 parent 7029e2e commit a30b9fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 47 deletions.
48 changes: 2 additions & 46 deletions .github/workflows/ci-terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ run-name: Terraform CI by @${{ github.actor }} ${{ github.sha }}

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
paths:
- ".github/workflows/ci-terraform.yml"
- "**.tf"
- "!examples/**"

concurrency:
Expand Down Expand Up @@ -38,47 +38,3 @@ jobs:
- 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>
// 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
})
}
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ run-name: Release by @${{ github.actor }} ${{ github.sha }}
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
steps:
- name: Checkout Repository
Expand All @@ -28,7 +32,7 @@ jobs:
- name: Set up Auto
uses: auto-it/setup-auto@v1
with:
gh-token: ${{ secrets.GITHUB_TOKEN }}
gh-token: ${{ secrets.GH_TOKEN }}

- name: Release
run: auto shipit

0 comments on commit a30b9fd

Please sign in to comment.