Skip to content

Commit d9dbca1

Browse files
committed
ci: resolve the PHP service name per checked-out revision
The populated-database job checks out the base branch before the pull request, so it sees two revisions of docker-compose.yml and cannot assume either service name.
1 parent c3f1e48 commit d9dbca1

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

.github/workflows/doctrine.yaml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,48 @@ jobs:
9090
run: |
9191
git checkout ${{ github.event.pull_request.base.sha }}
9292
93+
- name: Resolve the PHP service name
94+
run: |
95+
# This job straddles two revisions of docker-compose.yml: one
96+
# of them may still call the PHP service phpfpm while the
97+
# other calls it frankenphp.
98+
if docker compose config --services | grep -qx frankenphp; then
99+
echo "PHP_SERVICE=frankenphp" >> "$GITHUB_ENV"
100+
else
101+
echo "PHP_SERVICE=phpfpm" >> "$GITHUB_ENV"
102+
fi
103+
93104
- name: Run Composer Install
94105
run: |
95-
docker compose run --rm frankenphp composer install --no-interaction
106+
docker compose run --rm "$PHP_SERVICE" composer install --no-interaction
96107
97108
- name: Run Doctrine Migrations
98109
run: |
99-
docker compose run --rm frankenphp bin/console doctrine:migrations:migrate --no-interaction
110+
docker compose run --rm "$PHP_SERVICE" bin/console doctrine:migrations:migrate --no-interaction
100111
101112
- name: Load fixtures
102113
run: |
103-
docker compose run --rm frankenphp composer fixtures
114+
docker compose run --rm "$PHP_SERVICE" composer fixtures
104115
105116
- name: Check out the pull request
106117
run: |
107118
git checkout ${{ github.event.pull_request.head.sha }}
108119
120+
- name: Resolve the PHP service name
121+
run: |
122+
# This job straddles two revisions of docker-compose.yml: one
123+
# of them may still call the PHP service phpfpm while the
124+
# other calls it frankenphp.
125+
if docker compose config --services | grep -qx frankenphp; then
126+
echo "PHP_SERVICE=frankenphp" >> "$GITHUB_ENV"
127+
else
128+
echo "PHP_SERVICE=phpfpm" >> "$GITHUB_ENV"
129+
fi
130+
109131
- name: Run Composer Install
110132
run: |
111-
docker compose run --rm frankenphp composer install --no-interaction
133+
docker compose run --rm "$PHP_SERVICE" composer install --no-interaction
112134
113135
- name: Run Doctrine Migrations on the populated database
114136
run: |
115-
docker compose run --rm frankenphp bin/console doctrine:migrations:migrate --no-interaction
137+
docker compose run --rm "$PHP_SERVICE" bin/console doctrine:migrations:migrate --no-interaction

0 commit comments

Comments
 (0)