-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from sglkc/version-check
Add repository version check
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Check latest version | ||
|
||
on: | ||
schedule: | ||
- cron: "0 18 * * *" # scheduled at 06:00 (UTC+8) everyday | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check-in: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone Repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Fetch package.json from original repo | ||
run: | | ||
curl -o remote-package.json https://raw.githubusercontent.com/sglkc/hoyolab-auto-daily/master/package.json | ||
- name: Compare versions | ||
run: | | ||
LOCAL_VERSION=$(jq -r .version package.json) | ||
REMOTE_VERSION=$(jq -r .version remote-package.json) | ||
echo "Local version: $LOCAL_VERSION" | ||
echo "Remote version: $REMOTE_VERSION" | ||
if [ "$(printf '%s\n' "$REMOTE_VERSION" "$LOCAL_VERSION" | sort -V | head -n1)" != "$REMOTE_VERSION" ]; then | ||
echo "Local version is lower than remote version. Sync your repo!" | ||
exit 1 | ||
else | ||
echo "Local version is up to date." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters