From 6b78435ddccb2dc0baf013ecd39bc46d71bf059a Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 20:24:29 -0400 Subject: [PATCH 01/14] add support for helm docs --- README.md | 10 +--------- action.yaml | 57 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 7705586..0379dd1 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Action that runs updatecli, commits those changes if they exist, and opens a PR | Input | Description | Required | |-------|------------|----------| | manifest-path | Path to the updatecli manifest file. | true | +| run-helm-docs | Run helm-docs | false | | run-type | The type of updatecli run to perform. (major or minor) | true | ## Usage @@ -13,17 +14,8 @@ Action that runs updatecli, commits those changes if they exist, and opens a PR name: updatecli-minor "on": schedule: - # ┌───────────── minute (0 - 59) - # │ ┌───────────── hour (0 - 23) - # │ │ ┌───────────── day of the month (1 - 31) - # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) - # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) - # │ │ │ │ │ - # │ │ │ │ │ - # │ │ │ │ │ - cron: 0 15 * * 1 # Monday @ 3pm UTC workflow_dispatch: -# Do not grant jobs any permissions by default permissions: {} jobs: updatecli: diff --git a/action.yaml b/action.yaml index bbd9b5f..4088ec4 100644 --- a/action.yaml +++ b/action.yaml @@ -1,60 +1,81 @@ --- -name: Run updatecli and push to git +name: Run updatecli and open a PR with changes author: PrefectHQ description: This action will run updatecli and push the changes to git and will also open a PR inputs: manifest-path: - description: "Path to the updatecli manifest file" + description: Path to the updatecli manifest file default: ".github/updatecli/manifest-minor.yaml" required: true + run-helm-docs: + description: Run helm-docs + default: "false" + required: true run-type: - description: "The type of updatecli run to perform (major or minor)" + description: The type of updatecli run to perform (major or minor) default: "minor" required: true runs: using: composite steps: - - id: configure_git + - name: Configure git run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" shell: bash - - name: Get current date + - name: Get current date & determine branch name id: date - run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + run: | + echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + echo "BRANCH_NAME=dependency-version-${{ inputs.run-type }}-$DATE" >> $GITHUB_ENV shell: bash - - name: create branch for dependency version updates - run: git checkout -b "dependency-version-${{ inputs.run-type }}-${{ steps.date.outputs.date }}" + - name: Create branch for dependency version updates + run: | + git checkout -b $BRANCH_NAME shell: bash - - name: install updatecli in the runner + - name: Install updatecli in the runner uses: updatecli/updatecli-action@v2 - - name: run updatecli in apply mode + - name: Run updatecli in apply mode id: updatecli_apply run: | updatecli apply --config ${{ inputs.manifest-path }} --experimental if [[ $(git diff --name-only | wc -l) -eq 0 ]]; then echo "No changes detected, exiting" - echo "changes=false" >> $GITHUB_OUTPUT + echo "CHANGES=false" >> $GITHUB_ENV exit 0 else - echo "changes=true" >> $GITHUB_OUTPUT + echo "CHANGES=true" >> $GITHUB_ENV fi git add . - git commit -m "dependency-version-${{ inputs.run-type }}-${{ steps.date.outputs.date }}" - git push --set-upstream origin "dependency-version-${{ inputs.run-type }}-${{ steps.date.outputs.date }}" + git commit -m $BRANCH_NAME + git push --set-upstream origin $BRANCH_NAME env: GITHUB_TOKEN: ${{ github.token }} shell: bash - - name: create pr + - name: Install `helm-docs` + if: inputs.run-helm-docs == 'true' && env.CHANGES == 'true' + uses: jdx/mise-action@v2 + with: + install_args: helm-docs + + - name: Run `helm-docs` + if: inputs.run-helm-docs == 'true' && env.CHANGES == 'true' + run: | + helm-docs --template-files=README.md.gotmpl + git commit -am "helm-docs" + git push + shell: bash + + - name: Create PR if: steps.updatecli_apply.outputs.changes == 'true' run: | - git checkout "dependency-version-${{ inputs.run-type }}-${{ steps.date.outputs.date }}" - gh pr create --base main --title "dependency-version-${{ inputs.run-type }}-bump-${{ steps.date.outputs.date }}" -f --label soc2 + git checkout $BRANCH_NAME + gh pr create --base main --title $BRANCH_NAME -f --label soc2 env: - GITHUB_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ github.token }} shell: bash From 76e0a7cc8b7df7d9b753ee63baf64398cf8f745b Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 20:34:34 -0400 Subject: [PATCH 02/14] add test workflow --- .github/workflows/updatecli/manifest.yaml | 4 ++++ .github/workflows/validate-changes.yaml | 27 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 .github/workflows/updatecli/manifest.yaml create mode 100644 .github/workflows/validate-changes.yaml diff --git a/.github/workflows/updatecli/manifest.yaml b/.github/workflows/updatecli/manifest.yaml new file mode 100644 index 0000000..77fd96b --- /dev/null +++ b/.github/workflows/updatecli/manifest.yaml @@ -0,0 +1,4 @@ +--- +sources: {} +conditions: {} +targets: {} \ No newline at end of file diff --git a/.github/workflows/validate-changes.yaml b/.github/workflows/validate-changes.yaml new file mode 100644 index 0000000..ed500bc --- /dev/null +++ b/.github/workflows/validate-changes.yaml @@ -0,0 +1,27 @@ +--- +name: Validate Changes to Workflow + +"on": + pull_request: + branches: + - main + +permissions: {} + +jobs: + validate_changes: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: updatecli-minor-apply + uses: prefecthq/actions-updatecli-apply@${{ github.head_ref }} + with: + manifest-path: .github/updatecli/manifest.yaml + run-type: minor + + \ No newline at end of file From 5950f9e31dc6ded0e5bfecba84dcb0313b3e06f8 Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 20:38:29 -0400 Subject: [PATCH 03/14] standard linting / static analaysis --- .github/workflows/static-analysis.yaml | 26 +++++++++++++++++++++ .github/workflows/validate-changes.yaml | 6 +---- .github/yaml-lint/.config.yaml | 8 ------- .mise.toml | 5 ++++ .pre-commit-config.yaml | 31 +++++++++++++++++++++++++ .yamllint | 12 ++++++++++ 6 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/static-analysis.yaml delete mode 100644 .github/yaml-lint/.config.yaml create mode 100644 .mise.toml create mode 100644 .pre-commit-config.yaml create mode 100644 .yamllint diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml new file mode 100644 index 0000000..95d364b --- /dev/null +++ b/.github/workflows/static-analysis.yaml @@ -0,0 +1,26 @@ +--- +name: Static analysis + +"on": + pull_request: {} + +permissions: {} + +jobs: + pre_commit_checks: + name: pre-commit checks + runs-on: ubuntu-latest + permissions: + # required to read from the repo + contents: read + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Install tool dependencies + uses: jdx/mise-action@v2 + + - name: Run pre-commit + run: | + pre-commit run --show-diff-on-failure --color=always --all-files diff --git a/.github/workflows/validate-changes.yaml b/.github/workflows/validate-changes.yaml index ed500bc..d55c0c1 100644 --- a/.github/workflows/validate-changes.yaml +++ b/.github/workflows/validate-changes.yaml @@ -2,9 +2,7 @@ name: Validate Changes to Workflow "on": - pull_request: - branches: - - main + pull_request: {} permissions: {} @@ -23,5 +21,3 @@ jobs: with: manifest-path: .github/updatecli/manifest.yaml run-type: minor - - \ No newline at end of file diff --git a/.github/yaml-lint/.config.yaml b/.github/yaml-lint/.config.yaml deleted file mode 100644 index 16d21e2..0000000 --- a/.github/yaml-lint/.config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -config_data: | - extends: default - rules: - new-line-at-end-of-file: - level: warning - line-length: - max: 120 - level: warning diff --git a/.mise.toml b/.mise.toml new file mode 100644 index 0000000..ab4da37 --- /dev/null +++ b/.mise.toml @@ -0,0 +1,5 @@ +[tools] +actionlint = '1.7.1' +pre-commit = '3.8.0' +shellcheck = '0.10.0' +yamllint = '1.35.1' \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1f1375a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +--- +fail_fast: false + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: check-merge-conflict + - id: detect-private-key + - id: no-commit-to-branch + - id: trailing-whitespace + + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.28.0 + hooks: + - id: yamllint + args: + - --strict + + - repo: https://github.com/rhysd/actionlint + rev: v1.7.1 + hooks: + - id: actionlint + args: + - -shellcheck= + + - repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.7.2 + hooks: + - id: shellcheck + args: ["--severity=error"] diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..a194ddf --- /dev/null +++ b/.yamllint @@ -0,0 +1,12 @@ +--- +extends: default + +ignore: | + deploy/charts/ + +rules: + comments: + min-spaces-from-content: 1 + comments-indentation: disable + document-start: disable + line-length: disable From 7243e4307e9d95cd31899d854f016506d8dd12ec Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 20:38:52 -0400 Subject: [PATCH 04/14] update yamllint --- .yamllint | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.yamllint b/.yamllint index a194ddf..21751f7 100644 --- a/.yamllint +++ b/.yamllint @@ -1,12 +1,8 @@ --- extends: default -ignore: | - deploy/charts/ - rules: comments: min-spaces-from-content: 1 comments-indentation: disable - document-start: disable line-length: disable From 18fd44158ab4f4bb1914f98dc8ffafdbcae7ad1c Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 20:42:27 -0400 Subject: [PATCH 05/14] remove actionlint --- .github/workflows/updatecli/manifest.yaml | 2 +- .mise.toml | 1 - .pre-commit-config.yaml | 7 ------- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/updatecli/manifest.yaml b/.github/workflows/updatecli/manifest.yaml index 77fd96b..50118f8 100644 --- a/.github/workflows/updatecli/manifest.yaml +++ b/.github/workflows/updatecli/manifest.yaml @@ -1,4 +1,4 @@ --- sources: {} conditions: {} -targets: {} \ No newline at end of file +targets: {} diff --git a/.mise.toml b/.mise.toml index ab4da37..2479d8d 100644 --- a/.mise.toml +++ b/.mise.toml @@ -1,5 +1,4 @@ [tools] -actionlint = '1.7.1' pre-commit = '3.8.0' shellcheck = '0.10.0' yamllint = '1.35.1' \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f1375a..944d556 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,13 +17,6 @@ repos: args: - --strict - - repo: https://github.com/rhysd/actionlint - rev: v1.7.1 - hooks: - - id: actionlint - args: - - -shellcheck= - - repo: https://github.com/koalaman/shellcheck-precommit rev: v0.7.2 hooks: From c2bde7900ce391b76e944ea740c6072cb38eb6e5 Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 20:42:58 -0400 Subject: [PATCH 06/14] remove lint workflow --- .github/workflows/yaml-lint.yaml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .github/workflows/yaml-lint.yaml diff --git a/.github/workflows/yaml-lint.yaml b/.github/workflows/yaml-lint.yaml deleted file mode 100644 index 385dab1..0000000 --- a/.github/workflows/yaml-lint.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: lint yaml files - -"on": - pull_request: - branches: - - main - -jobs: - lintAllTheThings: - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - name: yaml-lint - uses: ibiqlik/action-yamllint@v3 - with: - config_file: .github/yaml-lint/.config.yaml From ebba4a343b26a93d8b116f2e895e3b8cd7989e0b Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 20:45:32 -0400 Subject: [PATCH 07/14] comments --- .github/workflows/static-analysis.yaml | 5 ++--- .github/workflows/validate-changes.yaml | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml index 95d364b..b3058e2 100644 --- a/.github/workflows/static-analysis.yaml +++ b/.github/workflows/static-analysis.yaml @@ -14,9 +14,8 @@ jobs: # required to read from the repo contents: read steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false + - name: checkout + uses: actions/checkout@v4 - name: Install tool dependencies uses: jdx/mise-action@v2 diff --git a/.github/workflows/validate-changes.yaml b/.github/workflows/validate-changes.yaml index d55c0c1..77c6950 100644 --- a/.github/workflows/validate-changes.yaml +++ b/.github/workflows/validate-changes.yaml @@ -8,9 +8,12 @@ permissions: {} jobs: validate_changes: + name: validate action changes runs-on: ubuntu-latest permissions: + # required to read from the repo contents: read + # required to read from the PR pull-requests: read steps: - name: checkout From ef5a11d77d693c43c586b445c9e901061449f736 Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 20:50:49 -0400 Subject: [PATCH 08/14] seperate steps --- action.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 4088ec4..9753fdc 100644 --- a/action.yaml +++ b/action.yaml @@ -24,10 +24,13 @@ runs: git config user.email "github-actions[bot]@users.noreply.github.com" shell: bash - - name: Get current date & determine branch name - id: date + - name: Get current date run: | echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + shell: bash + + - name: Determine branch name + run: | echo "BRANCH_NAME=dependency-version-${{ inputs.run-type }}-$DATE" >> $GITHUB_ENV shell: bash From 40c5aa999bf883f30df74df7ebb8de013bb0c58f Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 21:01:06 -0400 Subject: [PATCH 09/14] remove helm docs to start --- action.yaml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/action.yaml b/action.yaml index 9753fdc..a0e6b72 100644 --- a/action.yaml +++ b/action.yaml @@ -60,20 +60,6 @@ runs: GITHUB_TOKEN: ${{ github.token }} shell: bash - - name: Install `helm-docs` - if: inputs.run-helm-docs == 'true' && env.CHANGES == 'true' - uses: jdx/mise-action@v2 - with: - install_args: helm-docs - - - name: Run `helm-docs` - if: inputs.run-helm-docs == 'true' && env.CHANGES == 'true' - run: | - helm-docs --template-files=README.md.gotmpl - git commit -am "helm-docs" - git push - shell: bash - - name: Create PR if: steps.updatecli_apply.outputs.changes == 'true' run: | From 2ff0ba4060fb55211bc3ec612256bdecbce9d17a Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 21:05:22 -0400 Subject: [PATCH 10/14] use env --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index a0e6b72..fc489ec 100644 --- a/action.yaml +++ b/action.yaml @@ -61,7 +61,7 @@ runs: shell: bash - name: Create PR - if: steps.updatecli_apply.outputs.changes == 'true' + if: env.CHANGES == 'true' run: | git checkout $BRANCH_NAME gh pr create --base main --title $BRANCH_NAME -f --label soc2 From ae196aaa18ea8085309b980749921feca9fadf50 Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 21:05:27 -0400 Subject: [PATCH 11/14] use env --- action.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yaml b/action.yaml index fc489ec..bf54724 100644 --- a/action.yaml +++ b/action.yaml @@ -43,7 +43,6 @@ runs: uses: updatecli/updatecli-action@v2 - name: Run updatecli in apply mode - id: updatecli_apply run: | updatecli apply --config ${{ inputs.manifest-path }} --experimental if [[ $(git diff --name-only | wc -l) -eq 0 ]]; then From a62586e16f0d32eb42151eb4831e25b3bdf29e5b Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 21:07:30 -0400 Subject: [PATCH 12/14] add helm docs back --- action.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/action.yaml b/action.yaml index bf54724..f8a353c 100644 --- a/action.yaml +++ b/action.yaml @@ -59,6 +59,20 @@ runs: GITHUB_TOKEN: ${{ github.token }} shell: bash + - name: Install `helm-docs` + if: inputs.run-helm-docs == 'true' && env.CHANGES == 'true' + uses: jdx/mise-action@v2 + with: + install_args: helm-docs + + - name: Run `helm-docs` + if: inputs.run-helm-docs == 'true' && env.CHANGES == 'true' + run: | + helm-docs --template-files=README.md.gotmpl + git commit -am "helm-docs" + git push + shell: bash + - name: Create PR if: env.CHANGES == 'true' run: | From 0084dcc66d4c4df35e08dc74b376a225b271f3e2 Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 21:30:29 -0400 Subject: [PATCH 13/14] use local path --- .github/workflows/validate-changes.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-changes.yaml b/.github/workflows/validate-changes.yaml index 77c6950..bfe0314 100644 --- a/.github/workflows/validate-changes.yaml +++ b/.github/workflows/validate-changes.yaml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v4 - name: updatecli-minor-apply - uses: prefecthq/actions-updatecli-apply@${{ github.head_ref }} + uses: ./github/workflows/validate-changes.yaml with: manifest-path: .github/updatecli/manifest.yaml run-type: minor From 3b41f51dd4dfc67156101b7aeb2240b30a7af72a Mon Sep 17 00:00:00 2001 From: jamie zieziula Date: Mon, 7 Oct 2024 21:32:10 -0400 Subject: [PATCH 14/14] revert to this --- .github/workflows/validate-changes.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate-changes.yaml b/.github/workflows/validate-changes.yaml index bfe0314..77c6950 100644 --- a/.github/workflows/validate-changes.yaml +++ b/.github/workflows/validate-changes.yaml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@v4 - name: updatecli-minor-apply - uses: ./github/workflows/validate-changes.yaml + uses: prefecthq/actions-updatecli-apply@${{ github.head_ref }} with: manifest-path: .github/updatecli/manifest.yaml run-type: minor