This repository has been archived by the owner on Aug 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
2 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,34 @@ | ||
import os | ||
import sys | ||
import json | ||
import requests | ||
|
||
def main(version): | ||
modrinth_api = f"https://api.modrinth.com/v2/project/cF5VXmkW/version/{version}" | ||
github_project = os.environ["GITHUB_REPOSITORY"] | ||
headers = {"User-Agent": f"{github_project} (Verify Exist Script)"} | ||
|
||
response = requests.get(modrinth_api, headers=headers) | ||
|
||
if response.status_code == 200: | ||
json_data = json.loads(response.text) | ||
version_number = json_data["version_number"] | ||
date_published = json_data["date_published"] | ||
|
||
# Set step output | ||
with open(os.environ["GITHUB_OUTPUT"], "w") as f: | ||
f.write("version_exist=true") | ||
|
||
# Print a warning message | ||
print(f"::warning::版本 {version_number} 已存在!發佈時間 {date_published}。") | ||
else: | ||
print("版本未存在!") | ||
# Set step output | ||
with open(os.environ["GITHUB_OUTPUT"], "w") as f: | ||
f.write("version_exist=false") | ||
|
||
if __name__ == "__main__": | ||
git_version = sys.argv[1] | ||
if len(sys.argv) < 2: | ||
sys.exit(1) | ||
main(git_version) |
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
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,26 @@ | ||
name: Reusable | Verify Exist Version | ||
|
||
on: | ||
workflow_call: | ||
outputs: | ||
version_exist: | ||
description: "Version Exist" | ||
value: ${{ jobs.verify_exist.outputs.version_exist }} | ||
|
||
jobs: | ||
verify_exist: | ||
name: Verify Version Exist | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
version_exist: ${{ steps.verify.outputs.version_exist }} | ||
|
||
steps: | ||
- name: Checking Repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check version exist | ||
id: verify | ||
run: | | ||
GIT_VERSION=git-$(git rev-parse --short HEAD) | ||
python .github/scripts/modrinth_verify_exist.py $GIT_VERSION |