@@ -428,7 +428,9 @@ jobs:
428428 name : Generate CPU Profile
429429 runs-on : ubuntu-22.04
430430 needs : build-unsigned-snapshot
431- if : ${{ startsWith(github.head_ref, 'pgo-') && !github.event.pull_request.head.repo.fork }}
431+ if : ${{ github.event_name == 'push' &&
432+ startsWith(github.ref_name, 'pgo-') &&
433+ !github.event.pull_request.head.repo.fork }}
432434 permissions :
433435 contents : write
434436 steps :
@@ -444,13 +446,8 @@ jobs:
444446 cache : false
445447
446448 - name : Set env
447- run : |
448- echo "GO_VERSION=$(cat go.mod | grep toolchain | sed 's/toolchain //; s/go//')" >> $GITHUB_ENV
449- if [ ${{ github.head_ref }} ]; then
450- BRANCH_NAME=${{ github.head_ref }}
451- else
452- BRANCH_NAME=${GITHUB_REF#refs/heads/}
453- fi
449+ run : |
450+ - echo "GO_VERSION=$(cat go.mod | grep toolchain | sed 's/toolchain //; s/go//')" >> $GITHUB_ENV
454451
455452 - name : Download Packages
456453 uses : actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
@@ -488,11 +485,11 @@ jobs:
488485 git config --global user.name 'github-actions'
489486 git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
490487 git remote set-url origin 'https://github-actions:${{ secrets.GITHUB_TOKEN }}@github.com/nginx/agent.git'
491- git checkout -b $BRANCH_NAME -update-profile
488+ git checkout -b ${{ github.ref_name }} -update-profile
492489 git add default.pgo
493- git commit -m "Update pgo profile -- CI Autogenerated" -- ${{ steps.artifact-upload-step.outputs.artifact-id }} || echo "No changes to commit"
490+ git commit -m "Update pgo profile -- CI Autogenerated" || echo "No changes to commit"
494491 git log -1
495- git push -u origin "$BRANCH_NAME -update-profile"
492+ git push -u origin "${{ github.ref_name }} -update-profile"
496493
497494 - name : Create Pull Request
498495 uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@@ -504,8 +501,8 @@ jobs:
504501 title: 'Update pgo profile',
505502 owner,
506503 repo,
507- head: '$BRANCH_NAME -update-profile',
508- base: '$BRANCH_NAME ',
504+ head: '${{ github.ref_name }} -update-profile',
505+ base: '${{ github.ref_name }} ',
509506 state: 'open'
510507 });
511508 if (pullRequests.length > 0) {
@@ -521,8 +518,8 @@ jobs:
521518 title: 'Update pgo profile',
522519 owner,
523520 repo,
524- head: '$BRANCH_NAME -update-profile',
525- base: '$BRANCH_NAME ',
521+ head: '${{ github.ref_name }} -update-profile',
522+ base: '${{ github.ref_name }} ',
526523 body: [
527524 'This PR is auto-generated by the release workflow.'
528525 ].join('\n')
0 commit comments