Skip to content

GitHub Actions

Pat Brisbin edited this page Jul 23, 2024 · 5 revisions

Before using Restyled as a GitHub Action, make sure you prevent the hosted version from running. This can be done by uninstalling the GitHub App entirely, or configuring it for specific repositories and excluding the one where you plan to use GitHub Actions.

Then, create the file .github/workflows/restyled.yml:

on:
  pull_request:

jobs:
  restyled:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.ref }}
      - uses: restyled-io/restyler/actions/setup@main
      - id: restyler
        uses: restyled-io/restyler/actions/run@main

      # See below

After the above steps have run, if there were style differences, they were corrected and committed. You can then do some or all of the things described below by adding more steps to the jobs. Note that some of these steps may require adjusting Job permissions or using a Personal Access Token.

Manage a sibling "Restyled PR"

      - uses: peter-evans/create-pull-request@v6
        with:
          base: ${{ steps.restyler.outputs.restyled-base }}
          branch: ${{ steps.restyler.outputs.restyled-head }}
          title: ${{ steps.restyler.outputs.restyled-title }}
          body: ${{ steps.restyler.outputs.restyled-body }}
          labels: ${{ steps.restyler.outputs.restyled-labels }}
          reviewers: ${{ steps.restyler.outputs.restyled-reviewers }}
          team-reviewers: ${{ steps.restyler.outputs.restyled-team-reviewers }}
          delete-branch: true

Works for forks? No

Push the changes directly to the original PR

      - run: git push

Works for forks? Untested

Leave a comment on the original PR

# TODO

Works for forks? Yes

Emit failing status to the original PR

      - if: ${{ steps.restyler.outputs.differences == 'true' }}
        run: |
          echo "Restyled found differences" >&2
          exit 1

Works for forks? Yes

Clone this wiki locally