2 Commits
Author SHA1 Message Date
haylan a8f5680e6e fix(ci): update dev image build process and run tests in the same job
Tests / build-dev (push) Skipped
Tests / build-prod (push) Skipped
Tests / build-dev (pull_request) Successful in 1m14s
Tests / build-prod (pull_request) Successful in 3m20s
2026-07-31 14:17:39 +02:00
haylan 658892a639 fix(ci): remove redundant DEV_IMAGE variable and use REGISTRY directly for image tags 2026-07-31 14:07:07 +02:00
+25 -22
View File
@@ -8,7 +8,6 @@ on:
env: env:
REGISTRY: git.arthurerlich.de REGISTRY: git.arthurerlich.de
DEV_IMAGE: git.arthurerlich.de/${{ gitea.repository }}:ci-${{ gitea.sha }}
jobs: jobs:
build-dev: build-dev:
@@ -27,17 +26,30 @@ jobs:
username: ${{ gitea.actor }} username: ${{ gitea.actor }}
password: ${{ secrets.REGISTRY_TOKEN }} password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push dev image (PHP 8.4 + composer deps) - name: Build dev image (PHP 8.4 + composer deps)
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
file: Dockerfile.dev file: Dockerfile.dev
target: dev target: dev
push: true load: true
tags: ${{ env.DEV_IMAGE }} tags: graph-dev:ci
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev,mode=max cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev,mode=max
- name: Run tests in dev image
run: |
cid=$(docker create graph-dev:ci sh -c "
composer install --no-interaction &&
vendor/bin/phpunit --testdox &&
composer phpstan
")
docker cp . "$cid":/app
rc=0
docker start -a "$cid" || rc=$?
docker rm "$cid" > /dev/null
exit $rc
build-prod: build-prod:
needs: build-dev needs: build-dev
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -48,6 +60,13 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Log in to Gitea registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build prod image (final target) - name: Build prod image (final target)
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
@@ -55,21 +74,5 @@ jobs:
file: Dockerfile file: Dockerfile
target: final target: final
push: false push: false
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-prod
test: cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-prod,mode=max
needs: build-dev
runs-on: ubuntu-latest
container:
image: ${{ env.DEV_IMAGE }}
credentials:
username: ${{ gitea.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run tests
run: |
composer install --no-interaction
vendor/bin/phpunit --testdox
composer phpstan