mirror of
https://github.com/NatsumeLS/Gakumas-Translation-Data-EN.git
synced 2026-02-04 09:04:54 +00:00
chore(update.yml): rename dispatch.yml to update.yml
chore(update.yml): update name from Dispatch to Update chore(update.yml): update job name from dispatch to update chore(update.yml): add steps to checkout repository, authorize git, write branch and hash info, commit changes, and push to origin main chore(update.yml): update notification title from Dispatch to Update
This commit is contained in:
116
.github/workflows/update.yml
vendored
Normal file
116
.github/workflows/update.yml
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
name: Update
|
||||
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
validate:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
- name: Validate JSON and YAML
|
||||
id: json-yaml-validate
|
||||
uses: GrantBirki/json-yaml-validate@v3
|
||||
with:
|
||||
use_gitignore: false
|
||||
|
||||
- name: Validate Resource
|
||||
id: resource-validate
|
||||
run: python ./scripts/resource_validator.py ./local-files/resource
|
||||
|
||||
- name: Send Notification to Discord
|
||||
uses: sarisia/actions-status-discord@v1
|
||||
if: failure() && github.event_name != 'pull_request'
|
||||
with:
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: ${{ job.status }}
|
||||
title: "Validate"
|
||||
|
||||
format:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: validate
|
||||
|
||||
if: github.event_name != 'pull_request'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install --global prettier sort-json
|
||||
|
||||
- name: Run Prettier
|
||||
run: prettier --write "local-files/*.json" "local-files/**/*.json"
|
||||
|
||||
- name: Sort JSON files
|
||||
run: find local-files -type f -name '*.json' -not -path "local-files/genericTrans/lyrics/*" -exec sort-json {} +
|
||||
|
||||
- name: Authorize Git
|
||||
run: |
|
||||
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||
git config --global user.name "$GITHUB_ACTOR"
|
||||
|
||||
- name: Commit Changes
|
||||
run: |
|
||||
git add local-files/*.json local-files/**/*.json
|
||||
git commit -m "chore(format): Format and Sort JSON files"
|
||||
git push origin main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||
|
||||
update:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: [validate, format]
|
||||
|
||||
if: github.event_name != 'pull_request'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Authorize Git
|
||||
run: |
|
||||
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||
git config --global user.name "$GITHUB_ACTOR"
|
||||
|
||||
- name: Write Branch and Hash Info
|
||||
run: |
|
||||
branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
hash=$(git rev-parse --short=7 HEAD)
|
||||
echo "$branch.$hash" > version.txt
|
||||
echo "VERSION=$branch.$hash" >> $GITHUB_ENV
|
||||
|
||||
- name: Commit Changes
|
||||
run: |
|
||||
git commit -am "chore(update): Update Version Info"
|
||||
git push origin main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||
|
||||
- name: Send Notification to Discord
|
||||
uses: sarisia/actions-status-discord@v1
|
||||
if: always()
|
||||
with:
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: ${{ job.status }}
|
||||
title: "Update"
|
||||
Reference in New Issue
Block a user