Skip to content

Commit

Permalink
Separated auto-format workflow to be a reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gbruer15 committed Sep 4, 2024
1 parent acd8f46 commit 9ef9a53
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/auto-format.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: Auto-format
on:
pull_request:
types: [ready_for_review, synchronize]
branches:
- main
push:
branches:
- main
workflow_call:
inputs:
base_branch:
required: false
type: string
workflow_dispatch:
inputs:
base_branch:
Expand All @@ -23,15 +21,15 @@ jobs:
auto-format:
name: Run JuliaFormatter and create pull request
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.isDraft}}
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.isDraft }}
steps:
- name: Set inputs for push or pull request event
if: github.event_name != 'workflow_dispatch'
- name: Set base branch automatically
if: inputs.base_branch == ''
run: |
echo "base_branch=${{ github.head_ref || github.ref_name }}" >> $GITHUB_ENV
echo 'formatter_branch=auto-formatter/${{ github.head_ref || github.ref_name }}' >> $GITHUB_ENV
- name: Set inputs for workflow dispatch event
if: github.event_name == 'workflow_dispatch'
- name: Read base branch from inputs
if: inputs.base_branch
run: |
echo 'base_branch=${{ inputs.base_branch }}' >> $GITHUB_ENV
echo 'formatter_branch=auto-formatter/${{ inputs.base_branch }}' >> $GITHUB_ENV
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR Check
on:
pull_request:
types: [ready_for_review, synchronize]
branches:
- main
push:
branches:
- main

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

jobs:
auto-format:
uses: ./.github/workflows/auto-format.yaml
secrets: inherit

0 comments on commit 9ef9a53

Please sign in to comment.