Skip to content

Commit fdcda0a

Browse files
committed
Use github.ref_name as fallback for github.head_ref in e2e workflow
`github.head_ref` is only set on `pull_request` events; `workflow_dispatch` leaves it empty, whcih caused the `composer require` step to request an invalid "dev-" branch alias and fail.
1 parent 4fe5763 commit fdcda0a

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/e2e.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ jobs:
2121
php-version: "8.5"
2222
run: composer phpstan
2323

24+
env:
25+
HEAD_REF: ${{ github.head_ref || github.ref_name }}
26+
2427
steps:
28+
- name: Validate ref type
29+
if: github.event_name == 'workflow_dispatch' && github.ref_type != 'branch'
30+
run: |
31+
echo "::error::workflow_dispatch must be triggered from a branch, not a tag or other ref. Current ref: ${{ github.ref_name }} (type: ${{ github.ref_type }})"
32+
exit 1
33+
2534
- name: Checkout ${{ matrix.repo }}
2635
uses: actions/checkout@v6
2736
with:
@@ -47,8 +56,10 @@ jobs:
4756
env:
4857
GH_TOKEN: ${{ github.token }}
4958

50-
- name: Update the extension to "dev-${{ github.head_ref }} as ${{ steps.latest.outputs.version }}"
51-
run: composer require ${{ matrix.composer-params }} --dev "spaze/phpstan-disallowed-calls:dev-${{ github.head_ref }} as ${{ steps.latest.outputs.version }}" --with-all-dependencies
59+
- name: Update the extension to "dev-${{ env.HEAD_REF }} as ${{ steps.latest.outputs.version }}"
60+
env:
61+
LATEST_VERSION: ${{ steps.latest.outputs.version }}
62+
run: composer require ${{ matrix.composer-params }} --dev "spaze/phpstan-disallowed-calls:dev-${HEAD_REF} as ${LATEST_VERSION}" --with-all-dependencies
5263

5364
- name: Run tests
5465
run: ${{ matrix.run }}

0 commit comments

Comments
 (0)