Skip to content

Commit 13e7056

Browse files
committed
tag-git: allow running in private forks
On GitHub, forks of public repositories cannot be private, of course, but a fork can be created other than by clicking GitHub's `Fork` button... Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 7b6c324 commit 13e7056

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.github/workflows/tag-git.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ jobs:
7373
summary: "Tag ${{ env.MINGIT_ONLY == 'true' && 'Min' || '' }}Git @${{ env.REV }}"
7474
text: "For details, see [this run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id}})."
7575
details-url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id}}"
76+
- name: configure token
77+
if: github.repository_visibility == 'private'
78+
uses: actions/github-script@v7
79+
with:
80+
script: |
81+
const fs = require('fs')
82+
if (!fs.existsSync(process.env.HOME)) fs.mkdirSync(process.env.HOME)
83+
const { callGit, getPushAuthorizationHeader } = require('./repository-updates.js')
84+
for (const repo of ['build-extra', process.env.REPO]) {
85+
const header = await getPushAuthorizationHeader(
86+
console,
87+
core.setSecret,
88+
${{ secrets.GH_APP_ID }},
89+
${{ toJSON(secrets.GH_APP_PRIVATE_KEY) }},
90+
process.env.OWNER,
91+
repo
92+
)
93+
console.log(callGit(['config', '--global', `http.https://github.com/${process.env.OWNER}/${repo}.extraHeader`, header]))
94+
}
7695
- name: Configure user
7796
run: |
7897
USER_NAME="${{github.actor}}" &&
@@ -103,6 +122,10 @@ jobs:
103122
GPGKEY: ${{secrets.GPGKEY}}
104123
run: |
105124
git clone --bare --filter=blob:none https://github.com/git/git &&
125+
if test git-for-windows != "$OWNER"
126+
then
127+
git --git-dir=git.git fetch --tags --filter=blob:none https://github.com/git-for-windows/git
128+
fi &&
106129
git -C git.git fetch --tags --filter=blob:none "https://github.com/$OWNER/$REPO" "$RELEASE_BRANCH:refs/remotes/origin/$RELEASE_BRANCH" "$REV" &&
107130
108131
sh -x "$GITHUB_WORKSPACE/update-scripts/tag-git.sh" \

0 commit comments

Comments
 (0)