mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-20 07:39:42 +00:00
Trigger RestrictedActions Crowdin using cron job
same reason for this as why we trigger the branch sync from here - we need to make sure the cron doesn't get disabled RestrictedActions can do things this repo can't - the old workflow would've failed because GH Actions doesn't have pull_request write perms here (which we can't grant because it would also allow it to approve PRs)
This commit is contained in:
32
.github/workflows/crowdin-download-cron-trigger.yml
vendored
Normal file
32
.github/workflows/crowdin-download-cron-trigger.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
#Since GitHub automatically disables cron actions after 60 days of repo inactivity, we need the active repo (PM)
|
||||
#to trigger the branch merge workflow explicitly. This avoids the need for TOS-violating actions which we previously
|
||||
#used to keep the restricted action active, as the workflow depends on the activity of this repo anyway.
|
||||
|
||||
name: Trigger Crowdin download
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 21 * * *"
|
||||
workflow_dispatch: #for testing
|
||||
|
||||
jobs:
|
||||
trigger:
|
||||
name: Trigger Crowdin download RestrictedActions workflow
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Generate access token
|
||||
id: generate-token
|
||||
uses: actions/create-github-app-token@v2
|
||||
with:
|
||||
app-id: ${{ vars.RESTRICTED_ACTIONS_DISPATCH_ID }}
|
||||
private-key: ${{ secrets.RESTRICTED_ACTIONS_DISPATCH_KEY }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repositories: RestrictedActions
|
||||
|
||||
- name: Dispatch branch sync restricted action
|
||||
uses: peter-evans/repository-dispatch@v3
|
||||
with:
|
||||
token: ${{ steps.generate-token.outputs.token }}
|
||||
repository: ${{ github.repository_owner }}/RestrictedActions
|
||||
event-type: pocketmine_mp_crowdin_download
|
66
.github/workflows/download-translations.yml
vendored
66
.github/workflows/download-translations.yml
vendored
@@ -1,66 +0,0 @@
|
||||
name: Download new translations from Crowdin
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: 0 21 * * * #every day at 9pm
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
download:
|
||||
name: Download translations
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
branch:
|
||||
- stable
|
||||
- minor-next
|
||||
- major-next
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ matrix.branch }}
|
||||
|
||||
- name: Download translations
|
||||
uses: crowdin/github-action@v2
|
||||
with:
|
||||
upload_sources: false
|
||||
upload_translations: false
|
||||
download_translations: true
|
||||
create_pull_request: false
|
||||
push_translations: false
|
||||
export_only_approved: true #irrespective of project config, only accept approved translations here
|
||||
crowdin_branch_name: ${{ matrix.branch }}
|
||||
env:
|
||||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||
|
||||
- name: Post-process placeholders back into PocketMine format
|
||||
working-directory: resources/translations
|
||||
run: |
|
||||
sed -i -r 's/\{([A-Za-z0-9]+)\}/\{%\1\}/g' *.ini
|
||||
git diff
|
||||
git status
|
||||
|
||||
- name: Delete translation files with no translations
|
||||
working-directory: resources/translations
|
||||
run: |
|
||||
for file in *.ini; do
|
||||
if grep -q -P '^[A-Za-z0-9_\-\.]+=' $file; then
|
||||
echo "Not empty: $file"
|
||||
else
|
||||
echo "Deleting empty file: $file"
|
||||
rm "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
add-paths: '*.ini'
|
||||
commit-message: 'New translations from Crowdin (${{ matrix.branch }})'
|
||||
branch: crowdin-auto-fetch/${{ matrix.branch }}
|
||||
title: 'New translations from Crowdin'
|
||||
base: ${{ matrix.branch }}
|
Reference in New Issue
Block a user