From b90eb347cd0af5f36ba42b76278e6e4c83b2d238 Mon Sep 17 00:00:00 2001 From: Maurice Meyer Date: Fri, 7 Jul 2023 12:15:55 +0200 Subject: [PATCH] ci: only run helm docs on repo-internal PRs. --- .github/workflows/helm-docs-skip.yml | 12 ++++++ .github/workflows/helm-docs.yml | 12 +++++- .github/workflows/pre-commit.yml | 39 +++++++++++++++++++ .../renovate-config-validator-skip.yml | 12 ++++++ .../workflows/renovate-config-validator.yml | 3 +- CONTRIBUTING.md | 4 ++ renovate.json | 7 ++++ 7 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/helm-docs-skip.yml create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .github/workflows/renovate-config-validator-skip.yml diff --git a/.github/workflows/helm-docs-skip.yml b/.github/workflows/helm-docs-skip.yml new file mode 100644 index 00000000..fa1b170e --- /dev/null +++ b/.github/workflows/helm-docs-skip.yml @@ -0,0 +1,12 @@ +name: Helm Docs - Skip + +on: + push: + branches-ignore: + - renovate/** + +jobs: + helm-docs: + runs-on: ubuntu-latest + steps: + - run: echo "Not a renovate PR, nothing to do" diff --git a/.github/workflows/helm-docs.yml b/.github/workflows/helm-docs.yml index 279b80b2..97499a7a 100644 --- a/.github/workflows/helm-docs.yml +++ b/.github/workflows/helm-docs.yml @@ -1,13 +1,23 @@ name: Helm Docs on: - pull_request: + push: + branches: + - renovate/** + +permissions: + contents: write jobs: helm-docs: runs-on: ubuntu-latest + # Only run this for PRs from the charts repo itself (to auto-update docs for renovate PRs) + # For PRs made by humans, running pre-commit locally is required. + if: ${{ github.event.repository.name == "charts" }} steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 + with: + ref: ${{ github.head_ref }} - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4 with: diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..a82f7760 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,39 @@ +name: pre-commit + +on: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + + - name: Set up python + id: setup-python + uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1 + with: + python-version: 3.11.4 + + - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4 + with: + # renovate: go-version + go-version: 1.20.5 + + - name: Install helm-docs + # renovate: datasource=github-releases depName=norwoodj/helm-docs + run: go install github.com/norwoodj/helm-docs/cmd/helm-docs@v1.11.0 + + - name: Cache pre-commit dependencies + uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ steps.setup-python.outputs.python-version }}|${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Run pre-commit + uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507 # v3.0.0 diff --git a/.github/workflows/renovate-config-validator-skip.yml b/.github/workflows/renovate-config-validator-skip.yml new file mode 100644 index 00000000..a4380040 --- /dev/null +++ b/.github/workflows/renovate-config-validator-skip.yml @@ -0,0 +1,12 @@ +name: Validate renovate config - Skip + +on: + pull_request: + paths-ignore: + - renovate.json + +jobs: + renovate-validate: + runs-on: ubuntu-latest + steps: + - run: echo "renovate.json not changed, skipping" diff --git a/.github/workflows/renovate-config-validator.yml b/.github/workflows/renovate-config-validator.yml index 4917bd32..f70430a0 100644 --- a/.github/workflows/renovate-config-validator.yml +++ b/.github/workflows/renovate-config-validator.yml @@ -6,8 +6,7 @@ on: - renovate.json jobs: - validate: - name: Validate renovate config + renovate-validate: runs-on: ubuntu-latest steps: - name: Checkout diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a862dbbe..6438a966 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,8 +13,12 @@ Before you commit, please run pre-commit. This will also generate the documentat To set up pre-commit to run automatically on commit, run (example for Ubuntu) ```sh +# Linux pip3 install pre-commit +# macOS +brew install pre-commit + pre-commit install --hook-type commit-msg --hook-type pre-commit ``` diff --git a/renovate.json b/renovate.json index b23a7528..b5faf83b 100644 --- a/renovate.json +++ b/renovate.json @@ -89,6 +89,13 @@ "matchStrings": [ "# renovate: datasource=(?.*?)\\sdepName=(?.*?)\\s*run: go install github.com/norwoodj/helm-docs/cmd/helm-docs@(?.*)" ] + }, + { + "description": "Upgrade python-version version", + "fileMatch": ["(^workflow-templates|\\.github/workflows)/[^/]+\\.ya?ml$"], + "matchStrings": ["python-version:\\s(?.*)"], + "datasourceTemplate": "github-tags", + "depNameTemplate": "python/cpython" } ] }