File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,11 +24,23 @@ jobs:
2424 restore-keys : |
2525 ${{ runner.os }}-primes-
2626 - name : Install dependencies
27- if : steps.cache.outputs.cache-hit != 'true'
2827 run : npm ci
28+ - name : Create tsconfig.build.json
29+ run : |
30+ echo '{
31+ "extends": "./tsconfig.json",
32+ "compilerOptions": {
33+ "target": "ES2021",
34+ "module": "ES2020",
35+ "outDir": "./dist",
36+ "noEmit": false
37+ },
38+ "include": ["scripts/**/*"],
39+ "exclude": ["src/**/*", "dist"]
40+ }' > tsconfig.build.json
2941 - name : Build TypeScript
3042 run : |
31- npx tsc ./scripts/action-process-images.ts -- outDir ./dist --esModuleInterop --target ES2021 --jsx react --skipLibCheck
43+ npx tsc ./scripts/action-process-images.ts ./scripts/github-api.ts ./scripts/sharp-api.ts -- outDir ./dist --esModuleInterop --target ES2021 --module ES2020 --moduleResolution bundler --allowJs --isolatedModules -- skipLibCheck --jsx react
3244 - name : โง Process images and Report results
3345 run : node ./dist/action-process-images.js
3446 env :
Original file line number Diff line number Diff line change 1- import { createComment , createCommit , imageToTreeBlob } from './github-api'
2- import { sharpImages } from './sharp-api'
1+ import { createComment , createCommit , imageToTreeBlob } from './github-api.js '
2+ import { sharpImages } from './sharp-api.js '
33
44const formatByte = ( byte : number ) => {
55 let num = + byte
@@ -25,7 +25,9 @@ const formatImages = (num: number) => {
2525 }
2626
2727 console . log ( '\n::โง:: Generating Blobsโฆ' )
28- const imageBlobs = await Promise . all ( sharpedImageList . map ( imageToTreeBlob ) )
28+ const imageBlobs = await Promise . all (
29+ sharpedImageList . filter ( ( image ) => image . convertedToAvif && image . avifPath ) . map ( imageToTreeBlob )
30+ )
2931
3032 console . log ( '\n::โง:: Committing filesโฆ' )
3133 const commit = await createCommit ( {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import * as fs from 'node:fs/promises'
22
33import { Octokit , type RestEndpointMethodTypes } from '@octokit/rest'
44
5- import type { ProcessedResult } from './sharp-api'
5+ import type { ProcessedResult } from './sharp-api.js '
66
77export type GitTreeBlob = RestEndpointMethodTypes [ 'git' ] [ 'createTree' ] [ 'parameters' ] [ 'tree' ] [ number ]
88
@@ -37,6 +37,7 @@ const imageToBase64 = async (path: string) => {
3737}
3838
3939export const imageToTreeBlob = async ( image : ProcessedResult ) => {
40+ const filePath = image . convertedToAvif ? image . avifPath ! : image . path
4041 const encodedImage = await imageToBase64 ( image . path )
4142
4243 const blob = await api . rest . git . createBlob ( {
@@ -48,7 +49,7 @@ export const imageToTreeBlob = async (image: ProcessedResult) => {
4849 console . log ( 'โง' , image . name , blob . data . url )
4950
5051 return {
51- path : image . path ,
52+ path : filePath ,
5253 mode : '100644' ,
5354 type : 'blob' ,
5455 sha : blob . data . sha ,
You canโt perform that action at this time.
0 commit comments