mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows SK Contribution Guidelines (https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) - [ ] The code follows the .NET coding conventions (https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions) verified with `dotnet format` - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
80 lines
2.3 KiB
YAML
80 lines
2.3 KiB
YAML
name: Java format automation
|
|
on:
|
|
issue_comment:
|
|
types: [ created ]
|
|
|
|
jobs:
|
|
comment-driven-automation:
|
|
if: |
|
|
github.event.issue.pull_request &&
|
|
(
|
|
startsWith(github.event.comment.body, '/spotless') ||
|
|
startsWith(github.event.comment.body, '/help')
|
|
)
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
issues: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Get command
|
|
env:
|
|
BODY: ${{ github.event.comment.body }}
|
|
run: |
|
|
# intentionally only looking at the first line of the body
|
|
command=$(echo "$BODY" | head -1 | sed "s;^/;;")
|
|
echo "COMMAND=$command" >> $GITHUB_ENV
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Check out PR branch
|
|
env:
|
|
NUMBER: ${{ github.event.issue.number }}
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
gh pr checkout $NUMBER
|
|
if: env.COMMAND == 'spotless'
|
|
|
|
- name: Set up Maven cache
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: 17
|
|
distribution: microsoft
|
|
cache: maven
|
|
if: env.COMMAND == 'spotless'
|
|
|
|
- name: Set git user
|
|
run: |
|
|
git config user.name github-actions[bot]
|
|
git config user.email github-action[bot]@users.noreply.github.com
|
|
if: env.COMMAND == 'spotless'
|
|
|
|
- name: Run command
|
|
env:
|
|
NUMBER: ${{ github.event.issue.number }}
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
available_commands="Available commands:
|
|
* \`/spotless\` - runs \`./mvnw process-sources -DskipTests -Pbug-check\`
|
|
* \`/help\` - displays available commands
|
|
"
|
|
if [[ "$COMMAND" == "spotless" ]]; then
|
|
./mvnw process-sources -DskipTests -Pbug-check
|
|
if git diff --quiet; then
|
|
gh pr comment $NUMBER --body "Already up-to-date"
|
|
exit 0 # success
|
|
fi
|
|
git commit -a -m "./mvnw process-sources -DskipTests -Pbug-check"
|
|
git push
|
|
elif [[ "$COMMAND" == "help" ]]; then
|
|
gh pr comment $NUMBER --body "$available_commands"
|
|
else
|
|
body="Unknown command: \`$COMMAND\`
|
|
|
|
$available_commands
|
|
"
|
|
gh pr comment $NUMBER --body "$body"
|
|
fi
|
|
working-directory: java |