feat(ci): add GitHub Actions workflow for testing and Docker builds #20
+25
-21
@@ -26,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.REGISTRY }}/${{ gitea.repository }}:ci-${{ gitea.sha }}
|
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
|
||||||
@@ -47,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:
|
||||||
@@ -54,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.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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user