Skip to content

Update GitHub workflows for Gradle wrapper validation and Homebrew re… #46

Update GitHub workflows for Gradle wrapper validation and Homebrew re…

Update GitHub workflows for Gradle wrapper validation and Homebrew re… #46

name: Check formatting
on:
push:
tags:
- v*
branches:
- main
pull_request:
permissions:
contents: read
jobs:
check-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/setup-gradle@v3
- name: Run spotlessCheck and redirect output
run: ./gradlew spotlessCheck > spotless-output.txt 2>&1 || echo "failed" > spotless-status.txt
shell: bash
- name: Create comment
uses: actions/github-script@v5
with:
github-token: ${{ secrets.PAT }}
script: |
const fs = require('fs');
const issue_number = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const spotless_status = fs.readFileSync('spotless-status.txt', 'utf8').trim();
const spotless_output = fs.readFileSync('spotless-output.txt', 'utf8').trim();
if (spotless_status === 'failed') {
const body = `Spotless check ${spotless_status}.\n<details>\n<summary>Click to expand output</summary>\n\n\`\`\`\n${spotless_output}\n\`\`\`\n</details>`;
await github.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: issue_number,
body: body
});
}