Skip to content

Commit 0bba1f9

Browse files
(demo) Updates
1 parent 0902935 commit 0bba1f9

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.github/workflows/demo.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414

1515
concurrency:
1616
group: ${{ github.ref }}-demo
17-
cancel-in-progress: true
17+
cancel-in-progress: false
1818

1919
jobs:
2020
build:
@@ -33,6 +33,18 @@ jobs:
3333
uses: js-just/latest@main
3434
with:
3535
path: demo
36+
- name: Update latest ID
37+
uses: cpina/github-action-push-to-another-repository@main
38+
env:
39+
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
40+
with:
41+
source-directory: "demo-id"
42+
destination-github-username: js-just
43+
destination-repository-name: raw-api
44+
user-email: "[email protected]"
45+
target-branch: main
46+
target-directory: "demo-id"
47+
commit-message: "Update latest demo ID"
3648
- name: Commit
3749
uses: cpina/github-action-push-to-another-repository@main
3850
env:

src/demo.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ SOFTWARE.
2626

2727
const fs = require('fs');
2828
const path = require('path');
29-
30-
const [files] = process.argv.slice(2);
29+
const num_ = require('./modules/number.js');
30+
const [files, id] = process.argv.slice(2);
3131
const filess = JSON.parse(files);
3232
const types = [
3333
"md", "html", "js", "css"
@@ -36,4 +36,4 @@ filess.forEach(file => {
3636
fs.writeFileSync(path.join(process.cwd(), 'demo', `${file.name.replaceAll('.','')}.${types[file.type]}`), file.content, 'utf-8');
3737
});
3838

39-
console.log(String(0)); // output id.
39+
console.log(num_.convertbase(String(id), 10, 62));

src/demo.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222

2323
#!/bin/bash
2424
mkdir -p demo && \
25-
DEMO_BUILD_ID=$(node "src/demo.js" "$INPUT_FILES") && \
25+
DEMO_LATEST_ID=$(node "await fetch('https://raw.just.is-a.dev/demo-id/').then(async resp => {return await resp.json()}).then(resp => {console.log(resp.latest)})") && \
26+
DEMO_BUILT_ID=$(node "src/demo.js" "$INPUT_FILES" "$DEMO_LATEST_ID") && \
27+
DEMO_NEW_ID=$(node "console.log($DEMO_LATEST_ID + 1)") && \
2628
rm -f "just.config.js" && \
2729
echo "$INPUT_CONFIG" > just.config.js && \
28-
echo "id=$DEMO_BUILD_ID" >> $GITHUB_OUTPUT
30+
echo "id=id/$DEMO_BUILT_ID" >> $GITHUB_OUTPUT && \
31+
mkdir -p demo-id && \
32+
echo "{\"latest\":$DEMO_NEW_ID}" > "demo-id/index.js"

0 commit comments

Comments
 (0)