Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Restyled GitHub Action #162

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions .github/workflows/restyled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ name: Restyled

on:
pull_request:
types:
- opened
- reopened
- closed
- synchronize

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# For non-forks, we will maintain a sibling PR
restyled:
if: |
github.event.action != 'closed' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -21,10 +30,7 @@ jobs:
with:
fail-on-differences: true

- if: |
!cancelled() &&
steps.restyler.outputs.success == 'true' &&
github.event.pull_request.head.repo.full_name == github.repository
- if: ${{ !cancelled() && steps.restyler.outputs.success == 'true' }}
uses: peter-evans/create-pull-request@v7
with:
base: ${{ steps.restyler.outputs.restyled-base }}
Expand All @@ -34,3 +40,30 @@ jobs:
labels: "restyled"
reviewers: ${{ github.event.pull_request.user.login }}
delete-branch: true

# For forks, we will only run (and print git-am instructions)
restyled-fork:
if: |
github.event.action != 'closed' &&
github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: restyled-io/actions/setup@v4
- uses: restyled-io/actions/run@v4
with:
fail-on-differences: true

# On closed events clean up any leftover Restyled PRs
restyled-cleanup:
if: ${{ github.event.action == 'closed' }}
runs-on: ubuntu-latest
steps:
- uses: restyled-io/actions/setup@v4
- id: restyler
uses: restyled-io/actions/run@v4
- run: gh --repo "$REPO" pr close "$BRANCH" --delete-branch || true
env:
REPO: ${{ github.repository }}
BRANCH: ${{ steps.restyler.outputs.restyled-head }}
GH_TOKEN: ${{ github.token }}