- v6 -> v7 su tutti gli step, varianti gitea.com e -github - il breaking change della v7 (rifiuto del codice di una PR da fork su pull_request_target e workflow_run) era gia' backportato in v6.1.0, dove il tag flottante v6 puntava: il delta reale e' ESM piu' dipendenze - la guardia non si attiva comunque: serve un ref o un repository esplicito, e qui i checkout sono self-checkout nudi su workflow_call - action.yml identico fra v6.1.0 e v7.0.1, stesso using node24: nessun requisito nuovo sui runner Fixes #24 @1h30m
79 lines
2.7 KiB
YAML
79 lines
2.7 KiB
YAML
name: Dependency Outdated
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
working-directory:
|
|
description: 'Cartella che contiene package.json, relativa alla root del repo. Default: la root.'
|
|
type: string
|
|
default: '.'
|
|
node-version:
|
|
type: string
|
|
default: '24.16.0'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
dependency-outdated:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ inputs.working-directory || '.' }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@v7
|
|
|
|
- name: Setup Node.js
|
|
uses: https://github.com/actions/setup-node@v7
|
|
with:
|
|
node-version: ${{ inputs.node-version || '24.16.0' }}
|
|
# La cache npm resta allo step actions/cache: dalla v5 setup-node la accende
|
|
# da solo se package.json ha packageManager, e la duplicherebbe.
|
|
package-manager-cache: false
|
|
|
|
- name: Cache npm
|
|
uses: https://github.com/actions/cache@v6
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
|
|
- name: Configure npm private registry
|
|
run: |
|
|
echo "@pzeta:registry=https://gitea.pzetatouch.it/api/packages/PZeta_Touch/npm/" >> ~/.npmrc
|
|
echo "//gitea.pzetatouch.it/api/packages/PZeta_Touch/npm/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Check outdated packages
|
|
id: outdated
|
|
run: |
|
|
npm outdated --json > outdated.json 2>/dev/null || true
|
|
OUTDATED=$(jq 'keys | length' outdated.json 2>/dev/null || echo "0")
|
|
echo "count=$OUTDATED" >> $GITHUB_OUTPUT
|
|
|
|
- name: Open issue if packages outdated
|
|
if: steps.outdated.outputs.count != '0'
|
|
env:
|
|
GITEA_TOKEN: ${{ gitea.token }}
|
|
SERVER_URL: ${{ gitea.server_url }}
|
|
REPOSITORY: ${{ gitea.repository }}
|
|
run: |
|
|
OUTDATED="${{ steps.outdated.outputs.count }}"
|
|
DATE=$(date '+%Y-%m-%d')
|
|
|
|
OUTDATED_LIST=$(jq -r 'to_entries[] | "- \(.key): \(.value.current) → \(.value.latest)"' outdated.json 2>/dev/null | head -20 || echo "N/A")
|
|
|
|
printf '## Dipendenze Obsolete — %s\n\n### Pacchetti da aggiornare: %s\n\n```\n%s\n```\n' \
|
|
"$DATE" "$OUTDATED" "$OUTDATED_LIST" > /tmp/body.md
|
|
|
|
curl -s -X POST \
|
|
-H "Content-Type: application/json" \
|
|
-H "Authorization: token $GITEA_TOKEN" \
|
|
"$SERVER_URL/api/v1/repos/$REPOSITORY/issues" \
|
|
-d "{
|
|
\"title\": \"[$DATE] Dipendenze: $OUTDATED pacchetti obsoleti\",
|
|
\"body\": $(jq -Rs . /tmp/body.md)
|
|
}"
|