diff --git a/.github/workflows/ci-terraform.yml b/.github/workflows/ci-terraform.yml index a2dadef..1fc9b45 100644 --- a/.github/workflows/ci-terraform.yml +++ b/.github/workflows/ci-terraform.yml @@ -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: @@ -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 }}\` -
Validation Output - - \`\`\`\n - ${{ steps.validate.outputs.stdout }} - \`\`\` - -
- - // 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/release.yml b/.github/workflows/release.yml index 42c068a..1fb792f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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