From d6803697598e7aeac85b5891e1f51ea3f4139928 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Wed, 5 Feb 2025 08:57:35 +0200 Subject: [PATCH] chore: switch GITHUB_TOKEN to github.token, tweaks --- .editorconfig | 2 +- .gitignore | 1 + .markdownlint.json | 2 +- .pre-commit-config.yaml | 1 + .yamllint.yml | 2 +- csharp-publish/action.yml | 4 +-- pr-lint/action.yml | 6 ++-- release-monthly/README.md | 12 +++---- release-monthly/action.yml | 1 + run.sh | 72 ++++++++++++++++++++------------------ set-git-config/README.md | 12 +++---- set-git-config/action.yml | 2 +- 12 files changed, 62 insertions(+), 55 deletions(-) diff --git a/.editorconfig b/.editorconfig index f2c9e8c..25bbdb3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,7 +6,7 @@ end_of_line = lf indent_size = 2 indent_style = space insert_final_newline = true -max_line_length = 120 +max_line_length = 200 tab_width = 2 trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore index b5fce8a..4847a70 100644 --- a/.gitignore +++ b/.gitignore @@ -134,3 +134,4 @@ Homestead.json next-env.d.ts megalinter-reports/ +./update_* diff --git a/.markdownlint.json b/.markdownlint.json index 1fa630c..3de10f3 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,7 +1,7 @@ { "default": true, "MD013": { - "line_length": 120, + "line_length": 200, "code_blocks": false, "tables": false }, diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 272c95d..79591ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,4 @@ +--- repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 diff --git a/.yamllint.yml b/.yamllint.yml index baa0144..354fa2f 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -3,7 +3,7 @@ extends: default rules: line-length: - max: 120 + max: 200 level: warning truthy: check-keys: false diff --git a/csharp-publish/action.yml b/csharp-publish/action.yml index 4d13ee3..e322131 100644 --- a/csharp-publish/action.yml +++ b/csharp-publish/action.yml @@ -45,12 +45,12 @@ runs: - name: Publish Package shell: bash run: dotnet nuget push ./artifacts/*.nupkg \ - --api-key ${{ secrets.GITHUB_TOKEN }} \ + --api-key ${{ github.token }} \ --source "https://nuget.pkg.github.com/${{ inputs.namespace }}/index.json" \ --skip-duplicate \ --no-symbols \ || (sleep 5 && dotnet nuget push ./artifacts/*.nupkg \ - --api-key ${{ secrets.GITHUB_TOKEN }} \ + --api-key ${{ github.token }} \ --source "https://nuget.pkg.github.com/${{ inputs.namespace }}/index.json" \ --skip-duplicate \ --no-symbols) diff --git a/pr-lint/action.yml b/pr-lint/action.yml index 9255014..23832e6 100644 --- a/pr-lint/action.yml +++ b/pr-lint/action.yml @@ -16,7 +16,7 @@ runs: - name: Checkout Code uses: actions/checkout@v4 with: - token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + token: ${{ secrets.PAT || github.token }} # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to # improve performance @@ -54,7 +54,7 @@ runs: contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) }} - GITHUB_TOKEN: ${{ steps.git-config.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ steps.git-config.outputs.token || secrets.PAT || github.token }} # Apply linter fixes configuration # @@ -123,7 +123,7 @@ runs: id: cpr if: env.APPLY_FIXES_IF_PR == 'true' with: - token: ${{ steps.git-config.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }} + token: ${{ steps.git-config.outputs.token || secrets.PAT || github.token }} commit-message: '[MegaLinter] Apply linters automatic fixes' title: '[MegaLinter] Apply linters automatic fixes' labels: bot diff --git a/release-monthly/README.md b/release-monthly/README.md index 41a8aa5..6a89348 100644 --- a/release-monthly/README.md +++ b/release-monthly/README.md @@ -8,11 +8,11 @@ Creates a release for the current month, incrementing patch number if necessary. ### Inputs -| name | description | required | default | -| --------- | -------------------------------------------------------- | -------- | ------- | -| `token` |

GitHub token with permission to create releases.

| `true` | `""` | -| `dry-run` |

Run in dry-run mode without creating the release.

| `false` | `false` | -| `prefix` |

Optional prefix for release tags.

| `false` | `""` | +| name | description | required | default | +| --------- | -------------------------------------------------------- | -------- | --------------------- | +| `token` |

GitHub token with permission to create releases.

| `true` | `${{ github.token }}` | +| `dry-run` |

Run in dry-run mode without creating the release.

| `false` | `false` | +| `prefix` |

Optional prefix for release tags.

| `false` | `""` | ### Outputs @@ -35,7 +35,7 @@ This action is a `composite` action. # GitHub token with permission to create releases. # # Required: true - # Default: "" + # Default: ${{ github.token }} dry-run: # Run in dry-run mode without creating the release. diff --git a/release-monthly/action.yml b/release-monthly/action.yml index 079b460..e0c609b 100644 --- a/release-monthly/action.yml +++ b/release-monthly/action.yml @@ -12,6 +12,7 @@ inputs: token: description: 'GitHub token with permission to create releases.' required: true + default: '${{ github.token }}' dry-run: description: 'Run in dry-run mode without creating the release.' required: false diff --git a/run.sh b/run.sh index 6b9b088..88742d6 100755 --- a/run.sh +++ b/run.sh @@ -18,8 +18,8 @@ echo "πŸš€ Aloitetaan pΓ€ivitys $(date)" # Check required tools for cmd in npx sed find grep; do - if ! command -v $cmd &> /dev/null; then - echo "❌ Error: $cmd not found" | tee -a "$log_file" + if ! command -v $cmd &>/dev/null; then + echo "⚠️ Error: $cmd not found" | tee -a "$log_file" exit 1 fi done @@ -36,44 +36,50 @@ fi # Iterate over directories echo "πŸ“‚ Iterating over directories..." find . -mindepth 1 -maxdepth 1 -type d | while read -r dir; do - dir=${dir#./} - action="./$dir/action.yml" + ( + echo "πŸ” Found directory: $dir" + dir=${dir#./} + action="./$dir/action.yml" - # if action doesn't exist, skip - if [ ! -f "$action" ]; then - echo "⏩ Skipping $dir - action.yml missing" - continue - fi + if [ -f "$action" ]; then + echo "πŸ“„ Found action.yml in $dir" - repo="ivuorinen/actions/$dir" - readme="./$dir/README.md" - version=$(grep -E '^# version:' "$action" | cut -d ' ' -f 2) + repo="ivuorinen/actions/$dir" + readme="./$dir/README.md" + version=$(grep -E '^# version:' "$action" | cut -d ' ' -f 2) - # if version doesn't exist, use 'main' - if [ -z "$version" ]; then - version="main" - echo "ℹ️ Version not set in $dir/action.yml, using 'main'" - fi + # if version doesn't exist, use 'main' + if [ -z "$version" ]; then + version="main" + echo "ℹ️ Version not set in $dir/action.yml, using 'main'" + fi - echo "πŸ“ Updating $readme..." + echo "πŸ“ Updating $readme..." - printf "# %s\n\n" "$repo" >"$readme" + printf "# %s\n\n" "$repo" >"$readme" - echo "πŸ“„ Generating action documentation..." - if ! npx --yes action-docs@latest \ - --source="$action" \ - --no-banner \ - --include-name-header >>"$readme"; then - echo "⚠️ Warning: action-docs failed in $dir directory" | tee -a "$log_file" - fi + echo "πŸ“„ Generating action documentation..." + if ! npx --yes action-docs@latest \ + --source="$action" \ + --no-banner \ + --include-name-header >>"$readme"; then + echo "⚠️ Warning: action-docs failed in $dir directory" | tee -a "$log_file" + fi - echo "πŸ”„ Replacing placeholders in $readme..." - $SED_CMD "s|PROJECT|$repo|g; s|VERSION|$version|g; s|\*\*\*||g" "$readme" + echo "πŸ”„ Replacing placeholders in $readme..." + $SED_CMD "s|PROJECT|$repo|g; s|VERSION|$version|g; s|\*\*\*||g" "$readme" - if [ -f "$readme.bak" ]; then - rm "$readme.bak" - echo "πŸ—‘οΈ Removed $readme.bak" - fi + if [ -f "$readme.bak" ]; then + rm "$readme.bak" + echo "πŸ—‘οΈ Removed $readme.bak" + fi + else + # if action doesn't exist, skip + echo "⏩ Skipping $dir - action.yml missing" + fi + ) || { + echo "⚠️ Warning: Error processing directory $dir" | tee -a "$log_file" + } done echo "" @@ -105,5 +111,3 @@ if [ -f "$log_file" ]; then echo "- Warnings: $warnings" fi echo "- Status: βœ… Ready" - -echo "βœ… Ready!" diff --git a/set-git-config/README.md b/set-git-config/README.md index fdd2110..6f87963 100644 --- a/set-git-config/README.md +++ b/set-git-config/README.md @@ -8,11 +8,11 @@ Sets Git configuration for actions. ### Inputs -| name | description | required | default | -| ---------- | ----------------------------------- | -------- | ----------------------------- | -| `token` |

GitHub token.

| `false` | `${{ secrets.GITHUB_TOKEN }}` | -| `username` |

GitHub username for commits.

| `false` | `github-actions` | -| `email` |

GitHub email for commits.

| `false` | `github-actions@github.com` | +| name | description | required | default | +| ---------- | ----------------------------------- | -------- | --------------------------- | +| `token` |

GitHub token.

| `false` | `${{ github.token }}` | +| `username` |

GitHub username for commits.

| `false` | `github-actions` | +| `email` |

GitHub email for commits.

| `false` | `github-actions@github.com` | ### Outputs @@ -35,7 +35,7 @@ This action is a `composite` action. # GitHub token. # # Required: false - # Default: ${{ secrets.GITHUB_TOKEN }} + # Default: ${{ github.token }} username: # GitHub username for commits. diff --git a/set-git-config/action.yml b/set-git-config/action.yml index b1df985..f1b3d12 100644 --- a/set-git-config/action.yml +++ b/set-git-config/action.yml @@ -12,7 +12,7 @@ inputs: token: description: 'GitHub token.' required: false - default: '${{ secrets.GITHUB_TOKEN }}' + default: '${{ github.token }}' username: description: 'GitHub username for commits.' default: 'github-actions'