Paratranz To GitHub #28
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
name: Paratranz To GitHub | |
on: | |
schedule: | |
# 每天北京时间早上9点和晚上9点运行 | |
- cron: "0 1,13 * * *" | |
workflow_dispatch: | |
jobs: | |
paratranz-to-gitHub: | |
name: Paratranz To GitHub | |
environment: PARATRANZ_ENV | |
runs-on: ubuntu-latest | |
env: | |
API_TOKEN: ${{ secrets.API_KEY }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PROJECT_ID: ${{ vars.ID }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.13" | |
- name: Install dependencies | |
run: | | |
pip install requests | |
- name: Configure Git | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" && \ | |
git config --global user.name "VM[BOT]" | |
- name: Checkout main branch | |
run: git checkout main | |
- name: Paratranz To GitHub | |
run: python .github/workflows/para2github.py | |
- name: Commit changes | |
id: commit | |
run: | | |
if [[ -n $(git status -s) ]]; then | |
git add . | |
git commit -m '从Paratranz同步翻译' | |
git push origin main | |
echo "changed=true" >> $GITHUB_ENV | |
else | |
echo "changed=false" >> $GITHUB_ENV | |
fi | |
outputs: | |
changed: ${{ steps.commit.env.changed }} | |
release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
needs: paratranz-to-gitHub | |
if: ${{ needs.paratranz-to-gitHub.outputs.changed == 'true' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Upload CNPack folder | |
uses: actions/upload-artifact@v4 | |
with: | |
name: CNPack | |
path: ${{ github.workspace }}/CNPack | |
- name: Get current datetime for tag | |
id: datetime | |
run: echo "datetime=$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_ENV | |
- name: Zip CNPack folder | |
run: zip -r "${{ env.datetime }}.zip" ./CNPack | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ env.datetime }}.zip" | |
path: "${{ env.datetime }}.zip" | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "${{ env.datetime }}.zip" | |
tag: "Release-${{ env.datetime }}" | |
name: "Release ${{ env.datetime }}" | |
body: "自动生成的最新汉化补丁" | |
draft: false | |
prerelease: true |