Last active
February 12, 2022 04:08
-
-
Save xt0rted/d0eac04e15a7cea80aa974a4448defef to your computer and use it in GitHub Desktop.
GitHub Actions workflow to run dotnet-format from pr comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Format on Slash Command | |
on: | |
issue_comment: | |
types: created | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
jobs: | |
dotnet-format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check for command | |
id: command | |
uses: xt0rted/slash-command-action@v1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
command: dotnet | |
reaction-type: "eyes" | |
- name: Get branch info | |
if: steps.command.outputs.command-arguments == 'format' | |
id: comment-branch | |
uses: xt0rted/pull-request-comment-branch@v1 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout repo | |
if: success() | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ steps.comment-branch.outputs.ref }} | |
persist-credentials: false | |
- name: Restore dotnet tools | |
uses: xt0rted/dotnet-tool-restore@v1 | |
- run: dotnet-format | |
- name: Commit files | |
run: | | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git commit -a -m 'Automated dotnet-format update | |
Co-authored-by: ${{ github.event.comment.user.login }} <${{ github.event.comment.user.id }}+${{ github.event.comment.user.login }}@users.noreply.github.com>' | |
- name: Push changes | |
uses: ad-m/github-push-action@v0.5.0 | |
with: | |
branch: ${{ steps.comment-branch.outputs.ref }} | |
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment