repowarden 4.2.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/app +24 -7
- package/hooks/lib/i18n/en.sh +1 -0
- package/hooks/lib/i18n/fr.sh +1 -0
- package/package.json +1 -1
package/bin/app
CHANGED
|
@@ -90,7 +90,8 @@ else
|
|
|
90
90
|
if (process.env.ADMIN) perms.administration = "write";
|
|
91
91
|
const manifeste = JSON.stringify({
|
|
92
92
|
name: process.env.NOM, url: "https://github.com/" + process.env.REPO,
|
|
93
|
-
|
|
93
|
+
// Webhook inactif : GitHub exige tout de même son adresse
|
|
94
|
+
hook_attributes: { url: "https://github.com/" + process.env.REPO, active: false }, public: false,
|
|
94
95
|
redirect_url: "http://127.0.0.1:" + port + "/fin", default_permissions: perms,
|
|
95
96
|
}).replace(/&/g, "&").replace(/"/g, """);
|
|
96
97
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
@@ -114,8 +115,9 @@ else
|
|
|
114
115
|
reponse="$(gh api -X POST "app-manifests/$code/conversions")"
|
|
115
116
|
client_id="$(node -p 'JSON.parse(require("fs").readFileSync(0, "utf8")).client_id' <<<"$reponse")"
|
|
116
117
|
slug="$(node -p 'JSON.parse(require("fs").readFileSync(0, "utf8")).slug' <<<"$reponse")"
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
# Clé gardée en mémoire le temps de vérifier l'installation, jamais affichée
|
|
119
|
+
cle="$(node -e 'process.stdout.write(JSON.parse(require("fs").readFileSync(0, "utf8")).pem)' <<<"$reponse")"
|
|
120
|
+
printf '%s' "$cle" | gh secret set REPOWARDEN_APP_KEY --repo "$REPO"
|
|
119
121
|
reponse=""
|
|
120
122
|
gh variable set REPOWARDEN_APP_CLIENT_ID --repo "$REPO" --body "$client_id"
|
|
121
123
|
gh variable set REPOWARDEN_APP_SLUG --repo "$REPO" --body "$slug"
|
|
@@ -124,18 +126,33 @@ fi
|
|
|
124
126
|
|
|
125
127
|
# 2. Installation sur le dépôt (vérifiée depuis tes installations)
|
|
126
128
|
step_t app.step_install
|
|
129
|
+
# Vérifiée au nom de l'App (jeton signé avec sa clé, valable 10 min) : le jeton
|
|
130
|
+
# de gh ne peut pas lister les installations d'une App
|
|
127
131
|
installee() {
|
|
128
|
-
local
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
local jwt
|
|
133
|
+
jwt="$(CLE="$cle" CID="$client_id" node -e '
|
|
134
|
+
const c = require("crypto"), now = Math.floor(Date.now() / 1000);
|
|
135
|
+
const b = (o) => Buffer.from(JSON.stringify(o)).toString("base64url");
|
|
136
|
+
const t = b({ alg: "RS256", typ: "JWT" }) + "." + b({ iat: now - 60, exp: now + 540, iss: process.env.CID });
|
|
137
|
+
process.stdout.write(t + "." + c.sign("RSA-SHA256", Buffer.from(t), process.env.CLE).toString("base64url"));
|
|
138
|
+
' 2>/dev/null)" || return 1
|
|
139
|
+
gh api "repos/$REPO/installation" -H "Authorization: Bearer $jwt" >/dev/null 2>&1
|
|
132
140
|
}
|
|
141
|
+
cle="${cle:-}"
|
|
142
|
+
if [ -z "$cle" ]; then
|
|
143
|
+
# Relance (clé non disponible ici) : vérifiée au premier run du suivi des tickets
|
|
144
|
+
info_t app.check_in_ci "https://github.com/apps/$slug/installations/new"
|
|
145
|
+
echo
|
|
146
|
+
ok_t app.done
|
|
147
|
+
exit 0
|
|
148
|
+
fi
|
|
133
149
|
if [ -n "$slug" ] && ! installee; then
|
|
134
150
|
info_t app.open "https://github.com/apps/$slug/installations/new"
|
|
135
151
|
ouvrir "https://github.com/apps/$slug/installations/new"
|
|
136
152
|
for _ in $(seq 1 120); do installee && break; sleep 5; done
|
|
137
153
|
fi
|
|
138
154
|
if [ -n "$slug" ] && installee; then
|
|
155
|
+
cle=""
|
|
139
156
|
ok_t app.installed "$slug" "$REPO"
|
|
140
157
|
else
|
|
141
158
|
attention_t app.not_installed "$slug" "$REPO"
|
package/hooks/lib/i18n/en.sh
CHANGED
|
@@ -374,6 +374,7 @@ _msg_en() {
|
|
|
374
374
|
app.step_install) _M="Installing on the repository" ;;
|
|
375
375
|
app.installed) _M="App %s installed on %s." ;;
|
|
376
376
|
app.not_installed) _M="App %s not installed on %s yet: run repowarden app init again once installed." ;;
|
|
377
|
+
app.check_in_ci) _M="Installation checked by the first ticket tracking run (\"Jeton de l'App\" step); to install it: %s" ;;
|
|
377
378
|
app.done) _M="repowarden workflows now use the App: what they do triggers the other workflows." ;;
|
|
378
379
|
app.next) _M="Without the App (variable and secret missing), they fall back to the Actions token." ;;
|
|
379
380
|
tk.reopened) _M="Reopened: closed by GitHub when #%s was merged into \`%s\`, which is not production yet. In pre-production; it will be closed at the release." ;;
|
package/hooks/lib/i18n/fr.sh
CHANGED
|
@@ -374,6 +374,7 @@ _msg_fr() {
|
|
|
374
374
|
app.step_install) _M="Installation sur le dépôt" ;;
|
|
375
375
|
app.installed) _M="App %s installée sur %s." ;;
|
|
376
376
|
app.not_installed) _M="App %s pas encore installée sur %s : relance repowarden app init une fois installée." ;;
|
|
377
|
+
app.check_in_ci) _M="Installation vérifiée au premier run du suivi des tickets (étape « Jeton de l'App ») ; pour l'installer : %s" ;;
|
|
377
378
|
app.done) _M="Les workflows repowarden utilisent désormais l'App : ce qu'ils font déclenche les autres workflows." ;;
|
|
378
379
|
app.next) _M="Sans l'App (variable et secret absents), ils reprennent le jeton des Actions." ;;
|
|
379
380
|
tk.reopened) _M="Rouvert : fermé par GitHub au merge de #%s dans \`%s\`, ce n'est pas encore la production. En préprod ; il sera fermé à la release." ;;
|
package/package.json
CHANGED