Important
Before using Restyled as a GitHub Action, make sure you prevent any previous hosted installation from running. Otherwise, they may fight over the restyled branch. 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.
Create the file .github/workflows/restyled.yml:
name: Restyled
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
restyled:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: restyled-io/actions/setup@v2
- id: restyler
uses: restyled-io/actions/run@v2
# See belowThen, to determine what happens when style has been corrected, add some of the things described below, salted to taste.
- 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 }}
delete-branch: true
# If desired:
# labels: "restyled"
# reviewers: ${{ github.event.pull_request.user.login }}
# team-reviewers: "..."Required permissions: contents:write, pull-requests:write.
Works for forks? No.
- run: git pushRequired permissions: contents:write.
Works for forks? No
- if: ${{ steps.restyler.outputs.differences == 'true' }}
run: |
echo "Restyled found differences" >&2
exit 1Or, if you don't need additional steps to run after this (or you configure them
to always run), you can change the run invocation to:
- id: restyler
uses: restyled-io/actions/run@v2
with:
fail-on-differences: trueRequired permission: none.
Works for forks? Yes
This happens by default and appears in the output of the run step:
Apply this patch locally with the following command:
echo '...' | base64 -d | git am
Required permission: none.
Works for forks? Yes
name: Restyled
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
restyled:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: restyled-io/restyler/setup@v2
- id: restyler
uses: restyled-io/restyler/run@v2
with:
fail-on-differences: true
# Manage a sibling PR if we're not a fork
- if: ${{ !cancelled() && github.event.pull_request.head.repo.full_name == github.repository }}
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 }}
delete-branch: true
# If desired:
# labels: "restyled"
# reviewers: ${{ github.event.pull_request.user.login }}
# team-reviewers: "..."