Skip to content

Commit

Permalink
chore: update GitHub Workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed Aug 1, 2023
1 parent f0d43c0 commit 6271db3
Show file tree
Hide file tree
Showing 23 changed files with 129 additions and 245 deletions.
189 changes: 0 additions & 189 deletions .github/workflows/build.yml

This file was deleted.

71 changes: 60 additions & 11 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,66 @@ jobs:
build:
name: Build
if: ${{ github.repository == 'api-platform/demo' && (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'deploy')) }}
uses: ./.github/workflows/build.yml
with:
tags: |
type=raw,value=${{ github.sha }},priority=999
type=raw,value=latest,enable={{is_default_branch}},priority=900
push: true
gke-cluster: api-platform-demo
gke-zone: europe-west1-c
secrets:
gke-credentials: ${{ secrets.GKE_SA_KEY }}
gke-project: ${{ secrets.GKE_PROJECT }}
runs-on: ubuntu-latest
env:
PHP_DOCKER_IMAGE: eu.gcr.io/${{ secrets.GKE_PROJECT }}/php:${{ github.sha }}
CADDY_DOCKER_IMAGE: eu.gcr.io/${{ secrets.GKE_PROJECT }}/caddy:${{ github.sha }}
PWA_DOCKER_IMAGE: eu.gcr.io/${{ secrets.GKE_PROJECT }}/pwa:${{ github.sha }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# gcloud does not work with Python 3.10 because "collections.Mappings" was removed in Python 3.10.
-
uses: actions/setup-python@v4
with:
python-version: 3.9.15
-
name: Auth gcloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
-
name: Setup gcloud
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GKE_PROJECT }}
-
name: Configure gcloud
run: |
gcloud --quiet auth configure-docker
gcloud container clusters get-credentials api-platform-demo --zone europe-west1-c
-
name: Build Docker images
uses: docker/bake-action@v3
with:
pull: true
load: true
files: |
docker-compose.yml
docker-compose.prod.yml
set: |
*.cache-from=type=gha,scope=${{github.ref}}
*.cache-from=type=gha,scope=refs/heads/main
*.cache-to=type=gha,scope=${{github.ref}},mode=max
-
name: Docker tag latest
run: |
docker tag $PHP_DOCKER_IMAGE eu.gcr.io/${{ secrets.GKE_PROJECT }}/php:latest
docker tag $CADDY_DOCKER_IMAGE eu.gcr.io/${{ secrets.GKE_PROJECT }}/caddy:latest
docker tag $PWA_DOCKER_IMAGE eu.gcr.io/${{ secrets.GKE_PROJECT }}/pwa:latest
-
name: Docker push
run: |
docker push $PHP_DOCKER_IMAGE
docker push eu.gcr.io/${{ secrets.GKE_PROJECT }}/php:latest
docker push $CADDY_DOCKER_IMAGE
docker push eu.gcr.io/${{ secrets.GKE_PROJECT }}/caddy:latest
docker push $PWA_DOCKER_IMAGE
docker push eu.gcr.io/${{ secrets.GKE_PROJECT }}/pwa:latest
deploy:
name: Deploy
Expand Down
43 changes: 22 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,33 +82,34 @@ jobs:
uses: pnpm/action-setup@v2
with:
version: 8.6.2
-
name: Cache playwright binaries
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright
-
name: Install Playwright dependencies
working-directory: pwa
run: pnpm playwright install
-
name: Run Playwright
working-directory: pwa
# use 1 worker to prevent conflict between write and read scenarios
run: pnpm exec playwright test --workers=1
-
uses: actions/upload-artifact@v3
if: failure()
with:
name: playwright-screenshots
path: pwa/test-results
-
name: Doctrine Schema Validator
run: docker compose exec -T php bin/console doctrine:schema:validate
-
name: Psalm
run: docker compose exec -T php vendor/bin/psalm
# -
# name: Cache playwright binaries
# uses: actions/cache@v3
# with:
# path: ~/.cache/ms-playwright
# key: ${{ runner.os }}-playwright
# -
# name: Install Playwright dependencies
# working-directory: pwa
# run: pnpm playwright install
# -
# name: Run Playwright
# working-directory: pwa
# # use 1 worker to prevent conflict between write and read scenarios
# run: pnpm exec playwright test --workers=1
# -
# uses: actions/upload-artifact@v3
# if: failure()
# with:
# name: playwright-screenshots
# path: pwa/test-results

lint:
name: Docker Lint
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
contents: 'read'
id-token: 'write'
steps:
# gcloud does not work with Python 3.10 because collections.Mappings was removed in Python 3.10.
# gcloud does not work with Python 3.10 because "collections.Mappings" was removed in Python 3.10.
-
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
-
name: Checkout
uses: actions/checkout@v3
# gcloud does not work with Python 3.10 because collections.Mappings was removed in Python 3.10.
# gcloud does not work with Python 3.10 because "collections.Mappings" was removed in Python 3.10.
-
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
-
name: Checkout
uses: actions/checkout@v3
# gcloud does not work with Python 3.10 because collections.Mappings was removed in Python 3.10.
# gcloud does not work with Python 3.10 because "collections.Mappings" was removed in Python 3.10.
-
uses: actions/setup-python@v4
with:
Expand Down
5 changes: 4 additions & 1 deletion api/src/Serializer/BookNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public function normalize(mixed $object, string $format = null, array $context =
]);
$object->rating = $this->repository->getAverageRating($object);

return $this->normalizer->normalize($object, $format, $context + [self::class => true]);
/** @var array $data */
$data = $this->normalizer->normalize($object, $format, $context + [self::class => true]);

return $data;
}

public function supportsNormalization(mixed $data, string $format = null, array $context = []): bool
Expand Down
1 change: 1 addition & 0 deletions api/src/Serializer/IriTransformerNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function __construct(

public function normalize(mixed $object, string $format = null, array $context = []): array
{
/** @var array $data */
$data = $this->normalizer->normalize($object, $format, $context + [self::class => true]);

$value = $context[self::CONTEXT_KEY];
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: "3.8"
# Production environment override
services:
php:
image: ${PHP_DOCKER_IMAGE}
build:
context: ./api
target: php_prod
Expand All @@ -11,13 +12,15 @@ services:
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET}

pwa:
image: ${PWA_DOCKER_IMAGE}
build:
context: ./pwa
target: prod
environment:
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}

caddy:
image: ${CADDY_DOCKER_IMAGE}
build:
context: api/
target: caddy_prod
Expand Down
Loading

0 comments on commit 6271db3

Please sign in to comment.