Skip to content

Commit 8d53d4e

Browse files
committed
simplify token gen
1 parent 8026d6f commit 8d53d4e

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

.github/workflows/mg5_codegen.yml

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -46,44 +46,13 @@ jobs:
4646
echo "❌ clang-format check failed."
4747
fi
4848
49-
- name: Decode private key
50-
run: |
51-
echo "${{ secrets.GH_APP_PRIVATE_KEY }}" | base64 --decode > app.pem
52-
chmod 600 app.pem
53-
54-
- name: Generate installation token
49+
- name: Generate GitHub App token
5550
id: app-token
56-
uses: actions/github-script@v7
51+
uses: actions/create-github-app-token@v1
5752
with:
58-
script: |
59-
const fs = require("fs");
60-
const jwt = require("jsonwebtoken");
61-
62-
const privateKey = fs.readFileSync("app.pem", "utf8");
63-
64-
const now = Math.floor(Date.now() / 1000);
65-
const payload = {
66-
iat: now - 60,
67-
exp: now + 600,
68-
iss: process.env.APP_ID
69-
};
70-
71-
const token = jwt.sign(payload, privateKey, { algorithm: "RS256" });
72-
73-
const response = await github.request(
74-
"POST /app/installations/{installation_id}/access_tokens",
75-
{
76-
installation_id: process.env.APP_INSTALLATION_ID,
77-
headers: {
78-
authorization: `Bearer ${token}`
79-
}
80-
}
81-
);
82-
83-
return response.data.token;
84-
env:
85-
APP_ID: ${{ secrets.GH_APP_ID }}
86-
APP_INSTALLATION_ID: ${{ secrets.GH_APP_INSTALLATION_ID }}
53+
app-id: ${{ secrets.GH_APP_ID }}
54+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
55+
installation-id: ${{ secrets.GH_APP_INSTALLATION_ID }}
8756

8857
- name: Commit to target repository
8958
if: ${{ steps.clang-format-check.outputs.files2format == '8' }}
@@ -96,7 +65,7 @@ jobs:
9665
git config --global user.email "github-actions@users.noreply.github.com"
9766
9867
# Clone target repo
99-
git clone https://x-access-token:${{ steps.app-token.outputs.result }}@github.com/${TARGET_REPO}.git
68+
git clone https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${TARGET_REPO}.git
10069
cd madgraph4gpu-generated-processes
10170
10271
# Create branch based on PR number

0 commit comments

Comments
 (0)