fix: π guaspi content #836
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD with Docker | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] # Added to run checks on PRs | |
# Limit concurrent runs of this workflow | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true # Cancels in-progress runs when a new workflow is triggered | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
env: | |
TAG_NAME: ${{ github.sha }} | |
DOCKER_BUILDKIT: 1 # Enable BuildKit for faster builds | |
jobs: | |
build: | |
name: Build for GitHub Pages | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 # Shallow clone for faster checkout | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Cache npm dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.OS }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.OS }}-npm- | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
load: true | |
tags: lojban:latest | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
build-args: | | |
BUILDKIT_INLINE_CACHE=1 | |
NODE_ENV=production | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
- name: Run Docker container | |
run: | | |
docker run --rm -v /output:/app/src/out1 \ | |
-v ${{ github.workspace }}/data/config:/app/src/config:Z \ | |
-v ${{ github.workspace }}/data/pages:/app/src/md_pages:Z \ | |
-v ${{ github.workspace }}/data/assets:/app/src/public/assets:Z \ | |
-v ${{ github.workspace }}/data/DNS:/app/service/DNS:Z \ | |
-v ${{ github.workspace }}/src:/app/src:Z \ | |
-e GOOGLE_LOJBAN_CORPUS_DOC_ID=${{ secrets.GOOGLE_LOJBAN_CORPUS_DOC_ID }} \ | |
-e GOOGLE_READONLY_API_KEY=${{ secrets.GOOGLE_READONLY_API_KEY }} \ | |
-e CI=true \ | |
lojban:latest \ | |
sh -c "npm ci --prefer-offline && npx playwright install chromium --with-deps && npm run cicd" | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: /output/ | |
retention-days: 1 | |
deploy: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |