Skip to content

Commit 4ee65a3

Browse files
authored
fix: correct token passthrough (#44)
<!-- Thank you for your contribution! Please describe your PR --> These changes are required for correct work with GitHub App token - [x] - fix token passthrough where missing - [x] - add identity retrieval step for git configuration - [x] - configure git using env variables once Signed-off-by: t3mi <[email protected]>
1 parent 9784208 commit 4ee65a3

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

action.yml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,38 @@ runs:
109109
with:
110110
path: ${{ inputs.diff-storage }}
111111
fetch-depth: 0
112+
token: ${{ inputs.token }}
113+
114+
- name: Get token identity
115+
id: identity
116+
uses: octokit/[email protected]
117+
with:
118+
query: |
119+
query {
120+
viewer {
121+
databaseId
122+
login
123+
}
124+
}
125+
env:
126+
GITHUB_TOKEN: ${{ inputs.token }}
127+
128+
- name: Configure git
129+
run: |
130+
name="${{ fromJSON(steps.identity.outputs.data).viewer.login }}"
131+
email="${{ format('{0}+{1}@users.noreply.github.com', fromJSON(steps.identity.outputs.data).viewer.databaseId, fromJSON(steps.identity.outputs.data).viewer.login) }}"
132+
133+
cat >> "$GITHUB_ENV" << EOF
134+
GIT_AUTHOR_NAME=$name
135+
GIT_AUTHOR_EMAIL=$email
136+
GIT_COMMITTER_NAME=$name
137+
GIT_COMMITTER_EMAIL=$email
138+
EOF
139+
shell: bash
112140

113141
- name: Initialize storage branch
114142
working-directory: ${{ inputs.diff-storage }}
115143
run: |
116-
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
117-
git config --global user.name "github-actions[bot]"
118144
# Switch to the branch if it already exists
119145
git switch ${{ inputs.diff-storage }} || true
120146
git pull origin ${{ inputs.diff-storage }} || true
@@ -204,8 +230,6 @@ runs:
204230
- name: Commit badge
205231
working-directory: ${{ inputs.diff-storage }}/data
206232
run: |
207-
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
208-
git config --global user.name "github-actions[bot]"
209233
git switch ${{ inputs.diff-storage }} || true
210234
git pull origin ${{ inputs.diff-storage }}
211235
git add "${{ env.diff_storage_branch }}/${{ inputs.storage-subdirectory }}/badge.svg"
@@ -295,6 +319,7 @@ runs:
295319
if: contains(inputs.publish, 'true')
296320
uses: marocchino/sticky-pull-request-comment@v2
297321
with:
322+
GITHUB_TOKEN: ${{ inputs.token }}
298323
header: ${{ inputs.path }}
299324
path: .coverage-output.final
300325

@@ -312,8 +337,6 @@ runs:
312337
contains(inputs.diff, 'true')
313338
working-directory: ${{ inputs.diff-storage }}
314339
run: |
315-
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
316-
git config --global user.name "github-actions[bot]"
317340
git switch ${{ inputs.diff-storage }}
318341
git pull origin ${{ inputs.diff-storage }}
319342
filename=$(basename ${{ inputs.path }})

0 commit comments

Comments
 (0)