diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml new file mode 100644 index 0000000..b3058e2 --- /dev/null +++ b/.github/workflows/static-analysis.yaml @@ -0,0 +1,25 @@ +--- +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: + - name: checkout + uses: actions/checkout@v4 + + - 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/updatecli/manifest.yaml b/.github/workflows/updatecli/manifest.yaml new file mode 100644 index 0000000..50118f8 --- /dev/null +++ b/.github/workflows/updatecli/manifest.yaml @@ -0,0 +1,4 @@ +--- +sources: {} +conditions: {} +targets: {} diff --git a/.github/workflows/validate-changes.yaml b/.github/workflows/validate-changes.yaml new file mode 100644 index 0000000..77c6950 --- /dev/null +++ b/.github/workflows/validate-changes.yaml @@ -0,0 +1,26 @@ +--- +name: Validate Changes to Workflow + +"on": + pull_request: {} + +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 + 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 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 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..2479d8d --- /dev/null +++ b/.mise.toml @@ -0,0 +1,4 @@ +[tools] +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..944d556 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,24 @@ +--- +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/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..21751f7 --- /dev/null +++ b/.yamllint @@ -0,0 +1,8 @@ +--- +extends: default + +rules: + comments: + min-spaces-from-content: 1 + comments-indentation: disable + line-length: disable 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..f8a353c 100644 --- a/action.yaml +++ b/action.yaml @@ -1,60 +1,83 @@ --- -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 - id: date - run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + 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 - - 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 - id: updatecli_apply + - name: Run updatecli in apply mode 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 - if: steps.updatecli_apply.outputs.changes == 'true' + - 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: | - 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 + helm-docs --template-files=README.md.gotmpl + git commit -am "helm-docs" + git push + shell: bash + + - name: Create PR + if: env.CHANGES == 'true' + run: | + 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