chore: switch GITHUB_TOKEN to github.token, tweaks

This commit is contained in:
2025-02-05 08:57:35 +02:00
parent 0875e0e52e
commit d680369759
12 changed files with 62 additions and 55 deletions

View File

@@ -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

1
.gitignore vendored
View File

@@ -134,3 +134,4 @@ Homestead.json
next-env.d.ts
megalinter-reports/
./update_*

View File

@@ -1,7 +1,7 @@
{
"default": true,
"MD013": {
"line_length": 120,
"line_length": 200,
"code_blocks": false,
"tables": false
},

View File

@@ -1,3 +1,4 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0

View File

@@ -3,7 +3,7 @@ extends: default
rules:
line-length:
max: 120
max: 200
level: warning
truthy:
check-keys: false

View File

@@ -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)

View File

@@ -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

View File

@@ -8,11 +8,11 @@ Creates a release for the current month, incrementing patch number if necessary.
### Inputs
| name | description | required | default |
| --------- | -------------------------------------------------------- | -------- | ------- |
| `token` | <p>GitHub token with permission to create releases.</p> | `true` | `""` |
| `dry-run` | <p>Run in dry-run mode without creating the release.</p> | `false` | `false` |
| `prefix` | <p>Optional prefix for release tags.</p> | `false` | `""` |
| name | description | required | default |
| --------- | -------------------------------------------------------- | -------- | --------------------- |
| `token` | <p>GitHub token with permission to create releases.</p> | `true` | `${{ github.token }}` |
| `dry-run` | <p>Run in dry-run mode without creating the release.</p> | `false` | `false` |
| `prefix` | <p>Optional prefix for release tags.</p> | `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.

View File

@@ -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

72
run.sh
View File

@@ -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!"

View File

@@ -8,11 +8,11 @@ Sets Git configuration for actions.
### Inputs
| name | description | required | default |
| ---------- | ----------------------------------- | -------- | ----------------------------- |
| `token` | <p>GitHub token.</p> | `false` | `${{ secrets.GITHUB_TOKEN }}` |
| `username` | <p>GitHub username for commits.</p> | `false` | `github-actions` |
| `email` | <p>GitHub email for commits.</p> | `false` | `github-actions@github.com` |
| name | description | required | default |
| ---------- | ----------------------------------- | -------- | --------------------------- |
| `token` | <p>GitHub token.</p> | `false` | `${{ github.token }}` |
| `username` | <p>GitHub username for commits.</p> | `false` | `github-actions` |
| `email` | <p>GitHub email for commits.</p> | `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.

View File

@@ -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'