Skip to content

Commit

Permalink
auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
HolographicHat committed Nov 24, 2022
1 parent 881a1d9 commit 29bee51
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .github/update.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const utils = require("./utils");

(async () => {
try {
const latestVersionInfo = await utils.getAppVersion()
let releaseInfo = await utils.getLatestRelease()
if (releaseInfo.name !== latestVersionInfo["package_version"]) {
await utils.runWorkflow(41172724)
}
} catch (e) {
console.log(e)
}
})()
12 changes: 11 additions & 1 deletion .github/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ const uploadReleaseAsset = async (url, path) => {
})
}

module.exports = { getAppVersion, getLatestRelease, createRelease, uploadReleaseAsset }
const runWorkflow = async id => {
return await axios.post(`https://api.github.com/repos/${repo}/actions/workflows/${id}/dispatches`, {
ref: "master"
}, {
headers: {
"Authorization": `Bearer ${token}`,
}
})
}

module.exports = { getAppVersion, getLatestRelease, createRelease, uploadReleaseAsset, runWorkflow }
25 changes: 25 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Update Check

on:
schedule:
- cron: '0 12 * * *'

jobs:

build:
runs-on: ubuntu-latest
env:
GHP_TOKEN: ${{ secrets.GHP_TOKEN }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install depencies
run: npm install [email protected]
- name: Run script
run: node .github/update.js

0 comments on commit 29bee51

Please sign in to comment.