Fix CI source checkout on pull requests
On a pull_request event github.ref_name is the PR number (e.g. "29"),
not a fetchable ref, so the test job failed at "Récupérer les sources"
on every PR ("couldn't find remote ref 29"). Fetch the PR's head branch
(github.head_ref) instead, falling back to ref_name for pushes/tags.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b0d2100210
commit
56f969ba78
1 changed files with 4 additions and 1 deletions
|
|
@ -55,13 +55,16 @@ jobs:
|
||||||
# node:20-alpine n'a pas git préinstallé - même approche de clone
|
# node:20-alpine n'a pas git préinstallé - même approche de clone
|
||||||
# manuel que le job publish (pas d'actions/checkout, action JS qui a
|
# manuel que le job publish (pas d'actions/checkout, action JS qui a
|
||||||
# ses propres soucis dans les conteneurs Alpine minimalistes ici).
|
# ses propres soucis dans les conteneurs Alpine minimalistes ici).
|
||||||
|
# Sur une PR, `ref_name` vaut le numéro de la PR (ex. `29`), qui n'est
|
||||||
|
# pas une ref récupérable ("couldn't find remote ref 29") : on récupère
|
||||||
|
# alors la branche source de la PR (`head_ref`, vide hors PR).
|
||||||
- name: Récupérer les sources
|
- name: Récupérer les sources
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
apk add --no-cache git
|
apk add --no-cache git
|
||||||
git init -q
|
git init -q
|
||||||
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
|
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
|
||||||
git fetch -q --depth 1 origin "${{ github.ref_name }}"
|
git fetch -q --depth 1 origin "${{ github.head_ref || github.ref_name }}"
|
||||||
git checkout -q FETCH_HEAD
|
git checkout -q FETCH_HEAD
|
||||||
|
|
||||||
- name: Serveur - installer les dépendances
|
- name: Serveur - installer les dépendances
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue