Files
Gakumas-Translation-Data-EN/.github/workflows/dispatch.yml

106 lines
2.5 KiB
YAML

name: Dispatch
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@v3
with:
node-version: '16'
- name: Install Prettier and JSON Sort Plugin
run: npm install --global prettier prettier-plugin-sort-json
- name: Create Prettier Configuration
run: |
echo '{
"plugins": ["prettier-plugin-sort-json"],
"jsonRecursiveSort": true
}' > .prettierrc.json
- name: Run Prettier to format JSON files
run: prettier --write "local-files/**/*.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
git commit -m "chore(format): Format JSON files with Prettier"
git push origin main
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
dispatch:
runs-on: ubuntu-latest
needs: [validate, format]
if: github.event_name != 'pull_request'
steps:
- name: Dispatch Update Submodule to Gakumas-Localify-EN
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT }}
repository: NatsumeLS/Gakumas-Localify-EN
event-type: update-submodule
- name: Send Notification to Discord
uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
title: "Dispatch"