feat: trying to optimize builds
All checks were successful
Deploy to SFTP Server / build (push) Successful in 20m53s

This commit is contained in:
Max Richter
2025-10-25 13:34:18 +02:00
parent 22781de3eb
commit c96a13c734
7 changed files with 42 additions and 16 deletions

View File

@@ -20,15 +20,13 @@ jobs:
- name: 🔄 Checkout code - name: 🔄 Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: 🔢 Calculate cache IDs - name: 🔢 Prepare cache keys
run: | run: |
# Calculate cache IDs for Git LFS and PNPM # Calculate cache IDs for Git LFS
git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
LFS_CACHE_ID=$(cat .lfs-assets-id | md5sum)-v1 LFS_CACHE_ID=$(cat .lfs-assets-id | md5sum)-v1
PNPM_CACHE_ID=$(cat pnpm-lock.yaml | md5sum)-v1
echo "LFS_CACHE_ID=$LFS_CACHE_ID" >> $GITHUB_ENV echo "LFS_CACHE_ID=$LFS_CACHE_ID" >> $GITHUB_ENV
echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
echo "PNPM_CACHE_ID=$PNPM_CACHE_ID" >> $GITHUB_ENV
- name: 🗄️ Cache Git LFS objects - name: 🗄️ Cache Git LFS objects
uses: actions/cache@v4 uses: actions/cache@v4
@@ -41,12 +39,16 @@ jobs:
with: with:
path: ${{ env.PNPM_STORE_PATH }} path: ${{ env.PNPM_STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: 📷 Cache Astro Images - name: 📷 Cache Astro Images
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: node_modules/.astro path: node_modules/.astro
key: ${{ runner.os }}-astro-v1 key: ${{ runner.os }}-astro-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-astro-
- name: 🔄 Pull Git LFS files - name: 🔄 Pull Git LFS files
run: git lfs pull run: git lfs pull
@@ -70,8 +72,8 @@ jobs:
- name: 🚀 Deploy Changed Files via rclone - name: 🚀 Deploy Changed Files via rclone
run: | run: |
echo "Uploading _astro assets" echo "Uploading _astro assets"
rclone sync --update -v --progress --size-only --stats 2s --stats-one-line ./dist/_astro sftp-remote:${REMOTE_DIR}/_astro --transfers 4 rclone sync --update -v --progress --size-only --fast-list --stats 2s --stats-one-line ./dist/_astro sftp-remote:${REMOTE_DIR}/_astro --transfers 4
echo "Uploading the rest" echo "Uploading the rest"
rclone sync --update -v --progress --exclude _astro/** --stats 2s --stats-one-line ./dist/ sftp-remote:${REMOTE_DIR} --transfers 4 rclone sync --update -v --progress --exclude _astro/** --fast-list --stats 2s --stats-one-line ./dist/ sftp-remote:${REMOTE_DIR} --transfers 4
env: env:
REMOTE_DIR: ${{ vars.REMOTE_DIR }} REMOTE_DIR: ${{ vars.REMOTE_DIR }}

View File

@@ -65,6 +65,7 @@ const link = translatePath(`/${collection}/${id.split("/")[0]}`);
src={cover as ImageMetadata} src={cover as ImageMetadata}
alt={"cover for " + title} alt={"cover for " + title}
class="right-0 h-full object-cover object-center rounded-none border-l border-neutral" class="right-0 h-full object-cover object-center rounded-none border-l border-neutral"
thumbnail
/> />
</a> </a>
) )

View File

@@ -12,6 +12,7 @@ interface Props {
hash?: boolean; hash?: boolean;
loader?: boolean; loader?: boolean;
maxWidth?: number; maxWidth?: number;
thumbnail?: boolean;
} }
async function checkImage(image: ImageMetadata) { async function checkImage(image: ImageMetadata) {
@@ -41,16 +42,17 @@ const {
hash = true, hash = true,
alt, alt,
maxWidth, maxWidth,
thumbnail = false,
} = Astro.props; } = Astro.props;
const imageOk = await checkImage(image); const imageOk = await checkImage(image);
const imageBuffer = imageOk && await getImageBuffer(image); const imageBuffer = imageOk && (await getImageBuffer(image));
let thumbhash = imageBuffer && (await generateThumbHash(imageBuffer)); let thumbhash = imageBuffer && (await generateThumbHash(imageBuffer));
let exif = imageBuffer && (await getExifData(imageBuffer)); let exif = imageBuffer && (await getExifData(imageBuffer));
const sizes = [ const definedSizes = [
{ {
width: 240, width: 240,
media: "(max-width: 360px)", media: "(max-width: 360px)",
@@ -66,7 +68,11 @@ const sizes = [
{ {
width: image.width, width: image.width,
}, },
].filter((size) => !maxWidth || size.width <= maxWidth); ];
const sizes = thumbnail
? [definedSizes[0]]
: definedSizes.filter((size) => !maxWidth || size.width <= maxWidth);
--- ---
{ {

View File

@@ -1,13 +1,20 @@
--- ---
interface Props { interface Props {
title: string; title: string;
cover: string; cover?: string;
description?: string;
} }
const {
title,
cover,
description = "A personal blog and portfolio by Max Richter.",
} = Astro.props;
--- ---
<meta property="og:title" content={Astro.props.title} /> <meta property="og:title" content={title} />
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:url" content={Astro.url} /> <meta property="og:url" content={Astro.url} />
<meta property="og:image" content={Astro.props.cover} /> {cover && <meta property="og:image" content={cover} />}
<meta property="og:description" content="Max Richters personal blog" /> <meta property="og:description" content={description} />
<meta property="og:site_name" content="Max Richter" /> <meta property="og:site_name" content="Max Richter" />

View File

@@ -3,6 +3,7 @@ import { getCollection, render } from "astro:content";
import { getLocale } from "astro-i18n-aut"; import { getLocale } from "astro-i18n-aut";
import { filterCollection, parseSlug } from "@i18n/utils"; import { filterCollection, parseSlug } from "@i18n/utils";
import MetaTags from "@components/MetaTags.astro"; import MetaTags from "@components/MetaTags.astro";
import { markdownToText } from "@helpers/markdown";
const locale = getLocale(Astro.url); const locale = getLocale(Astro.url);
@@ -32,5 +33,9 @@ if (!page) {
const { Content } = await render(page); const { Content } = await render(page);
--- ---
<MetaTags title={page.data.title} cover={page.data.cover?.src} /> <MetaTags
title={page.data.title}
cover={page.data.cover?.src}
description={page.data.description || markdownToText(page.body).slice(0, 200)}
/>
<Content /> <Content />

View File

@@ -3,6 +3,7 @@ import { getCollection, render } from "astro:content";
import { getLocale } from "astro-i18n-aut"; import { getLocale } from "astro-i18n-aut";
import { filterCollection, parseSlug } from "@i18n/utils"; import { filterCollection, parseSlug } from "@i18n/utils";
import MetaTags from "@components/MetaTags.astro"; import MetaTags from "@components/MetaTags.astro";
import { markdownToText } from "@helpers/markdown";
const locale = getLocale(Astro.url); const locale = getLocale(Astro.url);
@@ -32,5 +33,9 @@ if (!page) {
const { Content } = await render(page); const { Content } = await render(page);
--- ---
<MetaTags title={page.data.title} cover={page.data.cover?.src} /> <MetaTags
title={page.data.title}
cover={page.data.cover?.src}
description={page.data.description || markdownToText(page.body).slice(0, 200)}
/>
<Content /> <Content />