Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/action-metadata-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Validate Action Metadata

on:
pull_request:
push:
branches:
- main

jobs:
action-metadata:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run actionlint
uses: reviewdog/actionlint@v1

- name: Verify action runtime and entrypoint convention
run: |
set -euo pipefail
failed=0
while IFS= read -r action_file; do
if ! grep -Eq "^[[:space:]]*using:[[:space:]]*'node20'[[:space:]]*$" "$action_file"; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse action metadata instead of grepping text

The convention step only checks whether a line matching using: 'node20'/main: 'dist/index.js' appears anywhere in the file, so it can pass invalid metadata when those strings appear in comments, examples, or unrelated sections while runs.using/runs.main are actually different. In that scenario the workflow reports success even though the action runtime/entrypoint convention is violated, which defeats the purpose of this guard; using a YAML-aware check (or yq on runs.*) would make the validation semantic rather than textual.

Useful? React with 👍 / 👎.

echo "[ERROR] $action_file must set runs.using to 'node20'"
failed=1
fi
if ! grep -Eq "^[[:space:]]*main:[[:space:]]*'dist/index.js'[[:space:]]*$" "$action_file"; then
echo "[ERROR] $action_file must set runs.main to 'dist/index.js'"
failed=1
fi
done < <(find . -mindepth 2 -maxdepth 2 -type f -name action.yml | sort)

if [ "$failed" -ne 0 ]; then
exit 1
fi
2 changes: 1 addition & 1 deletion notify-on-failure/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ inputs:
required: false
runs:
using: 'node20'
main: 'dist/index.js'
main: 'dist/index.js'
2 changes: 1 addition & 1 deletion notify-on-failure/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "notify-on-failure",
"version": "1.0.0",
"description": "GitHub Action for notifying Slack on push events",
"description": "GitHub Action for notifying Slack on workflow failure events",
"main": "dist/index.js",
"scripts": {
"build": "ncc build index.js -o dist"
Expand Down
Loading