Skip to content

Commit

Permalink
ci: improve installing and caching
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanChain committed Feb 6, 2025
1 parent 3ee8810 commit 8c61e1b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
26 changes: 11 additions & 15 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install pnpm
run: corepack enable
- name: Install packages
run: |
# See https://github.com/nodejs/corepack/issues/612#issuecomment-2629911771
export COREPACK_INTEGRITY_KEYS="$(curl https://registry.npmjs.org/-/npm/v1/keys | jq -c '{npm: .keys}')"
corepack pnpm install
- name: Restore image cache
id: image-restore
uses: actions/cache/restore@v4
uses: actions/cache@v4
with:
path: public/img/
key: image
key: image-${{ github.run_number }}
restore-keys: |
image
- name: Build pages
run: |
# See https://github.com/nodejs/corepack/issues/612#issuecomment-2629911771
export COREPACK_INTEGRITY_KEYS="$(curl https://registry.npmjs.org/-/npm/v1/keys | jq -c '{npm: .keys}')"
pnpm install
pnpm build
corepack pnpm gql-codegen
corepack pnpm build
mkdir -p dist/img
cp public/img/* dist/img
env:
Expand All @@ -61,12 +63,6 @@ jobs:
uses: actions/upload-pages-artifact@v3
with:
path: ./dist
- name: Always save cache
if: always() && steps.image-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: public/img/
key: image

deploy:
name: Deploy the Pages
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"preview": "astro preview",
"format": "prettier -w **/*.{js,json,ts,astro}",
"gql-codegen": "graphql-codegen --require dotenv/config",
"postinstall": "pnpm gql-codegen",
"prepare": "husky"
},
"lint-staged": {
Expand Down
7 changes: 5 additions & 2 deletions src/components/markdown/Image.astro
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ const imageBrightness = async (imageFile: string) => {
}
const downloadImage = async (hash: string): Promise<FileInfo> => {
const task = retry(async () => {
console.log(` Downloading ${hash} (${src})`)
const task = retry(async (bail, i) => {
if (i > 1) {
console.log(` Retry ${i}: ${hash} (${src})`)
}
const response = await axios({
method: 'GET',
url: src,
Expand Down Expand Up @@ -113,7 +117,6 @@ const getImageInfo = async () => {
console.log(` File corrupted ${hash} (${src}): ${err}`)
}
}
console.log(` Downloading ${hash} (${src})`)
try {
const fileInfo = await (downloadTasks.get(hash) || downloadImage(hash))
Expand Down

0 comments on commit 8c61e1b

Please sign in to comment.