All Projects → xt0rted → dotnet-format

xt0rted / dotnet-format

Licence: MIT license
A GitHub Action to run dotnet-format as part of your workflow

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to dotnet-format

Android-CICD
This repo demonstrates how to work on CI/CD for Mobile Apps 📱 using Github Actions 💊 + Firebase Distribution 🎉
Stars: ✭ 37 (+48%)
Mutual labels:  linting, github-actions
push-package-action
| Public | GitHub Action to Push a Package to Octopus Deploy
Stars: ✭ 23 (-8%)
Mutual labels:  github-actions
deploy-cloudrun
This action deploys your container image to Cloud Run.
Stars: ✭ 238 (+852%)
Mutual labels:  github-actions
pangyo-smilecook
🍱 Github Actions를 활용한 판교 한식뷔페 스마일쿡 식단 슬랙봇
Stars: ✭ 12 (-52%)
Mutual labels:  github-actions
dart-package-publisher
Action to Publish Dart / Flutter Package To https://pub.dev When you need to publish a package, just bump the version in pubspec.yaml
Stars: ✭ 45 (+80%)
Mutual labels:  github-actions
ghaction-cmake
cmake swiss army knife github docker action
Stars: ✭ 19 (-24%)
Mutual labels:  github-actions
csharp-docs-generator
An action that generates html documentation for C# programs to use for GitHub pages.
Stars: ✭ 21 (-16%)
Mutual labels:  github-actions
actions-clever-cloud
GitHub Action to deploy to Clever Cloud
Stars: ✭ 32 (+28%)
Mutual labels:  github-actions
Real Time Social Media Mining
DevOps pipeline for Real Time Social/Web Mining
Stars: ✭ 22 (-12%)
Mutual labels:  github-actions
actions-publish-gh-pages
🍣 A GitHub Action to publish static website using GitHub Pages
Stars: ✭ 12 (-52%)
Mutual labels:  github-actions
setup-jdk
(DEPRECATED) Set up your GitHub Actions workflow with a specific version of AdoptOpenJDK
Stars: ✭ 32 (+28%)
Mutual labels:  github-actions
hackernews-button
Privacy-preserving Firefox extension linking to Hacker News discussion; built with Bloom filters and WebAssembly
Stars: ✭ 73 (+192%)
Mutual labels:  github-actions
iOSDC2020-Talk-Sample
iOSDC 2020「GitHub ActionsでiOSアプリをCIする個人的ベストプラクティス」レギュラートークのサンプルリポジトリ
Stars: ✭ 35 (+40%)
Mutual labels:  github-actions
vue3-md-blog
✍️ Minimal config Vue3 + Markdown blog engine
Stars: ✭ 53 (+112%)
Mutual labels:  github-actions
review-pdf-generator-action
builds PDF via Re:VIEW and uploads as Artifacts
Stars: ✭ 15 (-40%)
Mutual labels:  github-actions
scan-action
Anchore container analysis and scan provided as a GitHub Action
Stars: ✭ 140 (+460%)
Mutual labels:  github-actions
apprise-ga
GitHub Action to send a dynamic push notification to every single platform thanks to the Apprise library
Stars: ✭ 18 (-28%)
Mutual labels:  github-actions
maven-settings-xml-action
Github Action to create maven settings (~/.m2/settings.xml)
Stars: ✭ 48 (+92%)
Mutual labels:  github-actions
actions-NjuHealthReport
Github Actions: 完成每日健康填报打卡,So easy
Stars: ✭ 68 (+172%)
Mutual labels:  github-actions
action-dotenv-linter
GitHub Action to run dotenv-linter ⚡️
Stars: ✭ 14 (-44%)
Mutual labels:  github-actions

GitHub Action for dotnet-format

CI CodeQL

Run dotnet-format v3 as part of your workflow to report formatting errors or auto fix violations as part of your pull request workflow.

Usage

Running on push.

name: Format check on push
on: push
jobs:
  dotnet-format:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2

      - name: Add dotnet-format problem matcher
        uses: xt0rted/dotnet-format-problem-matcher@v1

      - name: Restore dotnet tools
        uses: xt0rted/dotnet-tool-restore@v1

      - name: Run dotnet format
        uses: xt0rted/dotnet-format@v1

Running on pull_request.

name: Format check on pull request
on: pull_request
jobs:
  dotnet-format:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2

      - name: Add dotnet-format problem matcher
        uses: xt0rted/dotnet-format-problem-matcher@v1

      - name: Restore dotnet tools
        uses: xt0rted/dotnet-tool-restore@v1

      - name: Run dotnet format
        uses: xt0rted/dotnet-format@v1
        with:
          only-changed-files: "true"

Running on demand by pull request comment, triggered by the text /dotnet format.

The provided GITHUB_TOKEN will not trigger additional workflows. To push fixes back to the pull request branch you'll need to setup a secret with a Personal Access Token that has the repo scope.

name: Format on slash command
on:
  issue_comment:
    types: created
jobs:
  dotnet-format:
    runs-on: ubuntu-latest
    steps:
      - name: Check for command
        id: command
        uses: xt0rted/slash-command-action@v1
        continue-on-error: true
        with:
          command: dotnet
          reaction-type: "eyes"

      - name: Get branch info
        if: steps.command.outputs.command-name
        id: comment-branch
        uses: xt0rted/pull-request-comment-branch@v1
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Checkout repo
        if: steps.command.outputs.command-name
        uses: actions/checkout@v2
        with:
          ref: ${{ steps.comment-branch.outputs.ref }}
          persist-credentials: false

      - name: Restore dotnet tools
        if: steps.command.outputs.command-name
        uses: xt0rted/dotnet-tool-restore@v1

      - name: Run dotnet format
        if: steps.command.outputs.command-name && steps.command.outputs.command-arguments == 'format'
        id: format
        uses: xt0rted/dotnet-format@v1
        with:
          action: "fix"
          only-changed-files: true

      - name: Commit files
        if: steps.command.outputs.command-name && steps.command.outputs.command-arguments == 'format' && steps.format.outputs.has-changes == 'true'
        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
        if: steps.command.outputs.command-name && steps.command.outputs.command-arguments == 'format' && steps.format.outputs.has-changes == 'true'
        uses: ad-m/[email protected]
        with:
          branch: ${{ steps.comment-branch.outputs.ref }}
          github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

Token Permissions

If your repository is using token permissions, and you want to check only changed files, you'll need to set pull-request: read on either the workflow or the job.

Workflow Config

on: pull_request
permissions:
  pull-requests: read
jobs:
  dotnet-format:
    runs-on: ubuntu-latest
    steps:
      - name: Run dotnet format
        uses: xt0rted/dotnet-format@v1
        with:
          only-changed-files: "true"

Job Config

on: pull_request
jobs:
  dotnet-format:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: read
    steps:
      - name: Run dotnet format
        uses: xt0rted/dotnet-format@v1
        with:
          only-changed-files: "true"

Options

Required

Name Allowed values Description
repo-token GITHUB_TOKEN (default) or PAT GITHUB_TOKEN token or a repo scoped PAT.
version 3 (default) Version of dotnet-format to use.
action check (default), fix Primary action dotnet-format should perform.

Optional

Name Allowed values Description
only-changed-files true, false (default) Only changed files in the current pull request should be formatted.
fail-fast true (default), false The job should fail if there's a formatting error. Only used with the check action.

Outputs

Name Description
has-changes If any files were found to have violations or had fixes applied. Will be a string value of true or false.

License

The scripts and documentation in this project are released under the MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].