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 a796cc1
Show file tree
Hide file tree
Showing 21 changed files with 124 additions and 244 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
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
1 change: 1 addition & 0 deletions pwa/components/admin/book/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const ShowButton = (props: ShowButtonProps) => {
const record = useRecordContext(props);

return record ? (
// @ts-ignore
<Button label="Show" target="_blank" href={getItemPath({
id: record.id.replace(/^\/admin\/books\//, ""),
slug: slugify(`${record.title}-${record.author}`, { lower: true, trim: true, remove: /[*+~.(),;'"!:@]/g }),
Expand Down
2 changes: 2 additions & 0 deletions pwa/components/book/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const List: NextPage<Props> = ({ data, hubURL, filters, page }) => {
FetchResponse<PagedCollection<Book>> | undefined,
Error | FetchError,
FiltersProps
// @ts-ignore
>(async (filters) => {
router.push(buildUriFromFilters("/books", filters));
});
Expand All @@ -45,6 +46,7 @@ export const List: NextPage<Props> = ({ data, hubURL, filters, page }) => {
<FilterListOutlinedIcon className="w-6 h-6 mr-1"/>
Filters
</div>
{/* @ts-ignore */}
<Filters mutation={filtersMutation} filters={filters}/>
</aside>
<div className="float-right w-[1010px] justify-center">
Expand Down
Loading

0 comments on commit a796cc1

Please sign in to comment.