Skip to content

Commit

Permalink
fix: check diff
Browse files Browse the repository at this point in the history
  • Loading branch information
riscait committed Nov 17, 2023
1 parent 486b596 commit 49ac8e5
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/check-all-lint-rule-diffs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Check diff
runs-on: ubuntu-latest
outputs:
diff_count: ${{ steps.output.outputs.diff_count }}
has_diff: ${{ steps.output.outputs.has_diff }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
Expand All @@ -26,34 +26,32 @@ jobs:
run: go run main.go
- name: output diff
id: output
run: echo "diff_count=$(git diff --name-only --relative=packages/altive_lints/lib | wc -l)" >> "$GITHUB_OUTPUT"

commit:
name: Commit diff
runs-on: ubuntu-latest
needs: [diff]
if: ${{ needs.diff.outputs.diff_count != '0' }}
steps:
- uses: actions/checkout@v4
run: echo "diff_count=$(git diff --name-only --relative=packages/altive_lints/lib | wc -l)" >> "$GITHUB_ENV"
- name: Create branch
if: env.diff_count != '0'
run: |
git switch -c ${{ env.branch }}
git push origin ${{ env.branch }}
- name: Git config
if: env.diff_count != '0'
run: |
git remote set-url origin https://github-actions:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Commit & Push
if: env.diff_count != '0'
run: |
git add .
git commit -m "feat: update all_lint_rules"
git push origin ${{ env.branch }}
- name: Output flag
run: echo "has_diff=${{ env.diff_count != '0' }}" >> "$GITHUB_OUTPUT"

pull-request:
name: Create Pull-Request
runs-on: ubuntu-latest
needs: [commit]
needs: [diff]
if: needs.diff.outputs.has_diff == 'true'
steps:
- uses: actions/checkout@v4
- name: Generate GiHub App token
Expand Down

0 comments on commit 49ac8e5

Please sign in to comment.