Skip to content

Commit

Permalink
Merge branch 'feature/CSC-1652-gh-action-for-processing-custom-sheets…
Browse files Browse the repository at this point in the history
…' into staging
  • Loading branch information
danielxvu committed Oct 1, 2023
2 parents cbfe5ec + a807baa commit e8efc3b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/use-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
env:
NPM_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
CDN_SHEETS_FOLDER: ${{ vars.CDN_SHEETS_FOLDER }}
DEST_DIR: /tmp
steps:
- uses: actions/checkout@v3
- id: 'auth'
Expand All @@ -99,4 +100,4 @@ jobs:
args: fd-find
- run: make clean
- run: make all
- run: bash force-update.sh
- run: bash force-update.sh "$DEST_DIR"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ clean:
rm -rf **/*/dist

all:
fd . --exclude contrib --exclude "Zelda BOTW" --type d --max-depth 1 --exec bun run contrib/sheet-pixie/index.ts "{}/sheet.json" \;
fd . --strip-cwd-prefix --exclude contrib --exclude "Zelda BOTW" --type d --max-depth 1 --exec bun run contrib/sheet-pixie/index.ts "{}/sheet.json" \;
21 changes: 5 additions & 16 deletions contrib/sheet-pixie/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,9 @@ async function onSheetChange(sheetDir: string) {
const cssRes = await tryCss(Bun.file(`${sheetDir}/${cssPath}`), advanced);
const { css, rawCss } = cssRes;

const data = {
characterSheet: {
css,
rawCss,
html,
mancertemplates,
rolltemplates,
sheetworkers,
},
};

const distDir = `${sheetDir}/dist`;
const distDir = `${process.env.DEST_DIR}/${sheetDir}/dist`;
rmSync(distDir, { recursive: true, force: true });
mkdirSync(distDir);
mkdirSync(distDir, { recursive: true });
await Promise.all([
saveToFile(`${distDir}/index.html`, html),
saveToFile(`${distDir}/index.css`, css),
Expand All @@ -75,14 +64,14 @@ async function main(args: string[]) {
}

let jobStatus = 0;
const args = Bun.argv.slice(2);

main(Bun.argv.slice(2))
main(args)
.then()
.catch((err) => {
console.error(err);
console.error(Bun.stderr, `${err} (args=${args})`);
jobStatus = 1;
})
.finally(() => {
console.log({ jobStatus });
process.exit(jobStatus);
});
1 change: 0 additions & 1 deletion contrib/sheet-pixie/save.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function saveToFile(path: string, content: string) {
console.log("Writing content to file: " + path);
return Bun.write(path, content);
}
export { saveToFile };
2 changes: 1 addition & 1 deletion force-update.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

gcloud storage rsync --project=roll20-actual gs://roll20-cdn/$CDN_SHEETS_FOLDER --delete-unmatched-destination-objects --cache-control='no-cache'
gcloud storage rsync --project=roll20-actual $1 gs://roll20-cdn/$CDN_SHEETS_FOLDER --delete-unmatched-destination-objects --cache-control='no-cache' --recursive

0 comments on commit e8efc3b

Please sign in to comment.