feat: use mpalmer/action-validator to validate the shared actions
This commit is contained in:
parent
76ebe0ec65
commit
dd0a4f28dd
2 changed files with 23 additions and 73 deletions
23
.forgejo/workflows/validate-shared-actions.yml
Normal file
23
.forgejo/workflows/validate-shared-actions.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
name: validate-shared-actions
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
validate-shared-actions:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Validate shared action metadata
|
||||
uses: mpalmer/action-validator@v0.9.0
|
||||
with:
|
||||
version: 0.9.0
|
||||
patterns: |
|
||||
:(glob)**/action.yml
|
||||
:(glob)**/action.yaml
|
||||
73
.github/workflows/validate-shared-actions.yml
vendored
73
.github/workflows/validate-shared-actions.yml
vendored
|
|
@ -1,73 +0,0 @@
|
|||
name: validate-shared-actions
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
validate-shared-actions:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
ACTIONLINT_VERSION: "1.7.8"
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://code.forgejo.org/actions/checkout@v4
|
||||
|
||||
- name: Restore actionlint cache
|
||||
id: cache-actionlint
|
||||
uses: https://data.forgejo.org/actions/cache/restore@v4
|
||||
with:
|
||||
path: .cache/tools/actionlint
|
||||
key: actionlint-${{ runner.os }}-${{ env.ACTIONLINT_VERSION }}
|
||||
|
||||
- name: Install actionlint (pinned + checksum)
|
||||
if: ${{ steps.cache-actionlint.outputs.cache-hit != 'true' }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
VERSION="${ACTIONLINT_VERSION}"
|
||||
OS="linux"
|
||||
ARCH="amd64"
|
||||
BASE_URL="https://github.com/rhysd/actionlint/releases/download/v${VERSION}"
|
||||
TAR="actionlint_${VERSION}_${OS}_${ARCH}.tar.gz"
|
||||
CHECKSUMS="checksums.txt"
|
||||
|
||||
INSTALL_DIR=".cache/tools/actionlint/${VERSION}"
|
||||
mkdir -p "${INSTALL_DIR}"
|
||||
|
||||
curl -fsSL "${BASE_URL}/${TAR}" -o "/tmp/${TAR}"
|
||||
curl -fsSL "${BASE_URL}/${CHECKSUMS}" -o "/tmp/${CHECKSUMS}"
|
||||
|
||||
grep " ${TAR}$" "/tmp/${CHECKSUMS}" > "/tmp/actionlint-sha256.txt"
|
||||
(cd /tmp && sha256sum -c actionlint-sha256.txt)
|
||||
|
||||
tar -xzf "/tmp/${TAR}" -C "${INSTALL_DIR}" actionlint
|
||||
chmod +x "${INSTALL_DIR}/actionlint"
|
||||
|
||||
- name: Save actionlint cache
|
||||
if: ${{ steps.cache-actionlint.outputs.cache-hit != 'true' }}
|
||||
uses: https://data.forgejo.org/actions/cache/save@v4
|
||||
with:
|
||||
path: .cache/tools/actionlint
|
||||
key: actionlint-${{ runner.os }}-${{ env.ACTIONLINT_VERSION }}
|
||||
|
||||
- name: Lint workflows with actionlint
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
ACTIONLINT_BIN=".cache/tools/actionlint/${ACTIONLINT_VERSION}/actionlint"
|
||||
if [ ! -x "${ACTIONLINT_BIN}" ]; then
|
||||
echo "actionlint binary missing: ${ACTIONLINT_BIN}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if compgen -G ".github/workflows/*.yml" > /dev/null || compgen -G ".github/workflows/*.yaml" > /dev/null; then
|
||||
"${ACTIONLINT_BIN}" -color
|
||||
else
|
||||
echo "No workflow files found in .github/workflows; skipping actionlint workflow lint"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue