Skip to content

Commit

Permalink
Merge pull request #4 from sglkc/version-check
Browse files Browse the repository at this point in the history
Add repository version check
  • Loading branch information
sglkc authored Jul 10, 2024
2 parents c1f5d74 + feb23f8 commit 6f14381
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/version.yml
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Today's check in status:
[![If you see this text, chances are the automation hasn't run. Do your setup below!](../../actions/workflows/login.yml/badge.svg)](../../actions/workflows/login.yml)

Repository version:
[![Do your setup!](../../actions/workflows/version.yml/badge.svg)](../../actions/workflows/version.yml)

## Table of Contents

- [Getting your cookie](#getting-your-cookie)
Expand Down

0 comments on commit 6f14381

Please sign in to comment.