@@ -1333,53 +1333,71 @@ jobs:
1333
1333
REF : " refs/tags/${{ steps.versionist.outputs.tag }}"
1334
1334
SHA : ${{ steps.create_tag.outputs.sha }}
1335
1335
1336
- # Checkout the versioned commit we created in the previous steps.
1337
- # This may seem wasteful, to clone the sources again, but we plan to move
1338
- # the versioning steps above out of Flowzone entirely and clone from a
1339
- # branch created by a dedicated GitHub App.
1340
- - name : Checkout versioned commit
1341
- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1336
+ # # Checkout the versioned commit we created in the previous steps.
1337
+ # # This may seem wasteful, to clone the sources again, but we plan to move
1338
+ # # the versioning steps above out of Flowzone entirely and clone from a
1339
+ # # branch created by a dedicated GitHub App.
1340
+ # - name: Checkout versioned commit
1341
+ # uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1342
+ # with:
1343
+ # # Should be 0 (full depth) if submodules are present, otherwise 1
1344
+ # fetch-depth: ${{ steps.git_describe.outputs.depth || 0 }}
1345
+ # # Note that fetch-tags is not currently working as described:
1346
+ # # https://github.com/actions/checkout/issues/1781
1347
+ # fetch-tags: false
1348
+ # submodules: "recursive"
1349
+ # # fallback to an invalid ref if the checkout ref is undefined
1350
+ # ref: "${{ steps.create_commit.outputs.sha || '¯\_(ツ)_/¯' }}"
1351
+ # path: versioned-source
1352
+ # <<: *checkoutAuth
1353
+
1354
+ # Create base64 encoded auth header
1355
+ - name : Create base64 encoded auth header
1356
+ id : auth_header
1357
+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
1358
+ env :
1359
+ GIT_AUTH_TOKEN : ${{ steps.gh_app_token.outputs.token || secrets.FLOWZONE_TOKEN }}
1342
1360
with :
1343
- # Should be 0 (full depth) if submodules are present, otherwise 1
1344
- fetch-depth : ${{ steps.git_describe.outputs.depth || 0 }}
1345
- # Note that fetch-tags is not currently working as described:
1346
- # https://github.com/actions/checkout/issues/1781
1347
- fetch-tags : false
1348
- submodules : " recursive"
1349
- # fallback to an invalid ref if the checkout ref is undefined
1350
- ref : " ${{ steps.create_commit.outputs.sha || '¯\_ (ツ)_/¯' }}"
1351
- path : versioned-source
1352
- << : *checkoutAuth
1353
-
1354
- # Create a local reference for the versioned tag.
1355
- # On open PRs, the tag doesn't exist yet, we couldn't fetch it anyway.
1356
- # On merged PRs, the tag fetch doesn't work correctly with fetch-depth > 0
1361
+ result-encoding : string
1362
+ script : |
1363
+ const token = process.env.GIT_AUTH_TOKEN;
1364
+ const authHeader = Buffer.from(`x-access-token:${token}`).toString('base64');
1365
+ core.setSecret(authHeader);
1366
+ core.setOutput('config', `http.https://github.com/.extraheader=Authorization: basic ${authHeader}`);
1367
+ return authHeader;
1368
+
1369
+ # Reset the local workspace to the versioned commit we just created
1370
+ # and add a local annotated tag.
1357
1371
# https://github.com/actions/checkout/issues/1781
1358
- - name : Create local tag for draft versions
1359
- if : inputs.disable_versioning != true
1360
- working-directory : versioned-source
1372
+ - name : Create a local versioned commit + tag
1373
+ if : steps.versionist.outputs.tag && steps.create_commit.outputs.sha
1361
1374
env :
1375
+ AUTH_CONFIG : ${{ steps.auth_header.outputs.config }}
1362
1376
GIT_AUTHOR_NAME : " ${{ steps.create_commit.outputs.author }}"
1363
1377
GIT_AUTHOR_EMAIL : " ${{ steps.create_commit.outputs.author_email }}"
1364
1378
GIT_COMMITTER_NAME : " ${{ steps.create_commit.outputs.author }}"
1365
1379
GIT_COMMITTER_EMAIL : " ${{ steps.create_commit.outputs.author_email }}"
1366
- REF : refs/tags/ ${{ steps.versionist.outputs.tag }}
1380
+ TAG : ${{ steps.versionist.outputs.tag }}
1367
1381
SHA : ${{ steps.create_commit.outputs.sha }}
1382
+ # Use git-c for non-persistent credential configuration
1383
+ #
1384
+ # The git -c option sets a configuration value for a single Git command invocation.
1385
+ # It does not modify any configuration files or persist the setting beyond this specific command.
1386
+ #
1387
+ # This approach ensures that the authentication credentials are used securely for this
1388
+ # specific operation without risk of unintended persistence or exposure in configuration files.
1368
1389
run : |
1369
- git update-ref "${REF}" "${SHA}"
1390
+ git -c "${AUTH_CONFIG}" fetch origin "${SHA}"
1391
+ git reset --hard "${SHA}"
1392
+ git tag --annotate "${TAG}" --message "${TAG}" --force
1370
1393
1371
1394
# Reset the .github directory to the GitHub ref
1372
1395
# For security, this is the tip of BASE if the event is pull_request_target
1373
1396
# or the merge commit if the PR is internal
1374
1397
- name : Reset .github directory to ${{ github.ref }}
1375
- working-directory : versioned-source
1376
1398
env :
1377
- GIT_AUTH_TOKEN : ${{ steps.gh_app_token .outputs.token || secrets.FLOWZONE_TOKEN }}
1399
+ AUTH_CONFIG : ${{ steps.auth_header .outputs.config }}
1378
1400
REF : ${{ github.ref }}
1379
- # Use bash without tracing to avoid leaking secrets
1380
- shell : bash
1381
- # Create base64 encoded auth header
1382
- #
1383
1401
# Use git-c for non-persistent credential configuration
1384
1402
#
1385
1403
# The git -c option sets a configuration value for a single Git command invocation.
@@ -1388,14 +1406,12 @@ jobs:
1388
1406
# This approach ensures that the authentication credentials are used securely for this
1389
1407
# specific operation without risk of unintended persistence or exposure in configuration files.
1390
1408
run : |
1391
- auth_header=$(printf "x-access-token:${GIT_AUTH_TOKEN}" | base64 | tr -d '\n')
1392
- git -c "http.https://github.com/.extraheader=Authorization: basic ${auth_header}" fetch origin "${REF}"
1409
+ git -c "${AUTH_CONFIG}" fetch origin "${REF}"
1393
1410
git checkout FETCH_HEAD -- .github
1394
1411
1395
1412
# Compress versioned source to maintain file permissions and case-sensitivity
1396
1413
# https://github.com/actions/upload-artifact#maintaining-file-permissions-and-case-sensitive-files
1397
1414
- name : Compress versioned source
1398
- working-directory : versioned-source
1399
1415
run : tar --auto-compress --create --file ${{ runner.temp }}/versioned_source.tar.zst .
1400
1416
1401
1417
# This artifact is consumed by all other jobs instead of re-cloning the sources.
0 commit comments