feat(ci): add GitHub Actions workflow for testing and Docker builds #20
+25
-21
@@ -26,17 +26,30 @@ jobs:
|
||||
username: ${{ gitea.actor }}
|
||||
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
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.dev
|
||||
target: dev
|
||||
push: true
|
||||
tags: ${{ env.REGISTRY }}/${{ gitea.repository }}:ci-${{ gitea.sha }}
|
||||
load: true
|
||||
tags: graph-dev:ci
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev
|
||||
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:
|
||||
needs: build-dev
|
||||
runs-on: ubuntu-latest
|
||||
@@ -47,6 +60,13 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
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)
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
@@ -54,21 +74,5 @@ jobs:
|
||||
file: Dockerfile
|
||||
target: final
|
||||
push: false
|
||||
|
||||
test:
|
||||
needs: build-dev
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.REGISTRY }}/${{ gitea.repository }}:ci-${{ gitea.sha }}
|
||||
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
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-prod
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-prod,mode=max
|
||||
|
||||
Reference in New Issue
Block a user