fix: use Hugo resource pipeline for blog cover images in list templates #48
This file contains hidden or 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: Deploy Production | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@v3 | |
| with: | |
| hugo-version: 'latest' | |
| extended: true | |
| - name: Cache Hugo resources | |
| uses: actions/cache@v4 | |
| with: | |
| path: resources/ | |
| key: hugo-resources-${{ hashFiles('content/**') }} | |
| restore-keys: hugo-resources- | |
| - name: Build Hugo | |
| run: hugo --minify | |
| - name: Remove original images where WebP exists | |
| run: | | |
| find public -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" \) | while read f; do | |
| dir=$(dirname "$f") | |
| base=$(basename "${f%.*}") | |
| if ls "${dir}/${base}_hu_"*.webp 2>/dev/null | grep -q .; then | |
| rm "$f" | |
| fi | |
| done | |
| echo "Verbleibende Bilddateien nach Cleanup:" | |
| find public -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" \) | wc -l | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=sha,prefix= | |
| type=raw,value=latest | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Copy docker-compose to server | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| source: "docker-compose.yml" | |
| target: "/opt/kidslab" | |
| overwrite: true | |
| - name: Deploy to server | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.SERVER_HOST }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SERVER_SSH_KEY }} | |
| script: | | |
| cd /opt/kidslab | |
| docker compose pull | |
| docker compose down | |
| docker compose up -d | |
| docker image prune -f |