generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To use the local and GHA version in cdcgov/cfa-gam-rt. These use the cache to run much faster. They also auto-commit changes when running, allowing for auto-formatting when accepting suggestions in PRs.
- Loading branch information
Showing
2 changed files
with
76 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,37 @@ | ||
name: pre-commit | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
branches: [main, prod] | ||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- uses: ./.github/actions/pre-commit | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
- uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cache/R/renv | ||
key: r-precommit-cache|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} | ||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
- name: Commit files | ||
if: failure() && startsWith(github.ref, 'refs/heads') | ||
run: | | ||
if [[ `git status --porcelain --untracked-files=no` ]]; then | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git checkout -- .github/workflows | ||
git commit -m "pre-commit" -a | ||
fi | ||
- name: Push changes | ||
if: failure() && startsWith(github.ref, 'refs/heads') | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{ github.ref }} | ||
env: | ||
RENV_CONFIG_CACHE_ENABLED: FALSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters