From e658d91c14fcc58adc8cd1fd1b6e3317031ce46d Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sat, 11 Dec 2021 11:46:22 +0100 Subject: [PATCH] add pre-commit via GHA --- .github/workflows/pre-commit.yaml | 55 +++++++++++++++++++++++++++++++ NEWS.md | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pre-commit.yaml diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 000000000..0cdf2e517 --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,55 @@ +name: pre-commit +on: + push: + branches-ignore: + - 'master' + - 'main' + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + pre-commit: + runs-on: ubuntu-18.04 + if: >- + !contains(github.event.head_commit.message, 'ci skip') && + ( + startsWith(github.ref, 'refs/heads') || + github.event.pull_request.draft == false + ) + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + # your system installation code here + # sudo apt-get install -y libcurl4-openssl-dev + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.8" + architecture: "x64" + - name: Run pre-commit + uses: pre-commit/action@v2.0.3 + - 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 diff --git a/NEWS.md b/NEWS.md index cc3809be8..178ea8380 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,7 +13,7 @@ * Bump minimal R requirement to 3.4 in line with the [tidyverse](https://www.tidyverse.org/blog/2019/04/r-version-support/), which allowed to remove the dependency at {backports} and some exception handling. * Remove dependency on {xfun} (#866). -* use bootstrap 5 with {pkgdown} 2.0 +* use pre-commit via GitHub Actions (#872). # styler 1.6.2