Skip to content

Commit 8a4c7a5

Browse files
author
LE SAULNIER Kevin
committed
add github app tokens
Signed-off-by: LE SAULNIER Kevin <[email protected]>
1 parent d727116 commit 8a4c7a5

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

.github/workflows/prepare-release.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,27 @@ jobs:
2323
submodules: false
2424
ref: release-workflow
2525

26-
- name: Auth GH CLI
27-
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
26+
- uses: actions/create-github-app-token@21cfef2b496dd8ef5b904c159339626a10ad380e # v1 v1.11.6
27+
id: app-token
28+
name: Generate app token
29+
with:
30+
app-id: ${{ vars.GRIDSUITE_ACTIONS_APPID }}
31+
private-key: ${{ secrets.VERSIONBUMP_GHAPP_PRIVATE_KEY }}
32+
33+
- name: Get GitHub App User ID
34+
id: get-user-id
35+
run: echo "user-id=$(gh api "/users/${RUNGHA_APP_SLUG}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
36+
env:
37+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
38+
RUNGHA_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} # just for defense against script injection
39+
40+
- name: Setup git user
41+
run: |
42+
git config --global user.name "${RUNGHA_APP_SLUG}[bot]"
43+
git config --global user.email "${RUNGHA_USER_ID}+${RUNGHA_APP_SLUG}[bot]@users.noreply.github.com"
44+
env:
45+
RUNGHA_APP_SLUG: ${{ steps.app-token.outputs.app-slug }} # just for defense against script injection
46+
RUNGHA_USER_ID: ${{ steps.get-user-id.outputs.user-id }} # just for defense against script injection
2847

2948
- name: Load repo list from file or input
3049
id: load_repos
@@ -57,16 +76,17 @@ jobs:
5776
cd public_repos
5877
5978
while read url; do
60-
git clone $url
79+
url_with_token="${url/https:\/\/github.com/https:\/\/x-access-token:${TOKEN}@github.com}"
80+
git clone "$url_with_token"
6181
folder=$(basename "$url" .git)
6282
cd $folder
63-
commit_date='${{ steps.load_date.outputs.date_value }}'
83+
commit_date="${{ steps.load_date.outputs.date_value }}"
6484
commit_hash=$(git rev-list -n 1 --before="$commit_date" main)
6585
git checkout $commit_hash
6686
6787
branch_name="prepare-release-${{github.event.inputs.release-version}}"
6888
# Check if *branch_name* already exists
69-
if git show-ref --verify --quiet "refs/heads/$branch_name"; then
89+
if git ls-remote --exit-code origin "refs/heads/$branch_name"; then
7090
echo "❌ Warning for $folder: Branch $branch_name already exists"
7191
exit 1
7292
fi
@@ -79,6 +99,8 @@ jobs:
7999
80100
commit_message=$(git log -1 --pretty=%s | cut -c1-50)
81101
82-
echo "✅ $folder tagged → $commit_hash | $commit_message"
102+
echo "✅ $folder : $branch_name branch created → $commit_hash | $commit_message"
83103
cd - > /dev/null
84-
done <<< "${{ steps.load_repos.outputs.list }}"
104+
done <<< "${{ steps.load_repos.outputs.list }}"
105+
env:
106+
TOKEN: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)