Skip to content

[translate] fa-IR: OpenVoiceOS/ovos-skill-date-time — date.not.found.dialog #168

[translate] fa-IR: OpenVoiceOS/ovos-skill-date-time — date.not.found.dialog

[translate] fa-IR: OpenVoiceOS/ovos-skill-date-time — date.not.found.dialog #168

name: Submit Translation PR
on:
issues:
types: [opened]
jobs:
create-pr:
if: contains(github.event.issue.labels.*.name, 'translation') || startsWith(github.event.issue.title, '[translate]')
runs-on: ubuntu-latest
steps:
- name: Parse issue body
id: parse
uses: actions/github-script@v7
with:
script: |
const body = context.payload.issue.body || '';
const meta = {};
// Parse <!-- TRANSLATION_META ... --> block
const match = body.match(/<!--\s*TRANSLATION_META\s+([\s\S]*?)-->/);
if (!match) {
core.setFailed('No TRANSLATION_META block found in issue body');
return;
}
for (const line of match[1].trim().split('\n')) {
const [key, ...rest] = line.split(':');
if (key && rest.length) meta[key.trim()] = rest.join(':').trim();
}
// Extract content between <content> tags
const contentMatch = body.match(/<content>([\s\S]*?)<\/content>/);
if (!contentMatch) {
core.setFailed('No <content> block found in issue body');
return;
}
for (const [k, v] of Object.entries(meta)) {
core.setOutput(k, v);
}
core.setOutput('content_b64', contentMatch[1].trim());
core.setOutput('author', context.payload.issue.user.login);
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.LOCALIZE_APP_ID }}
private-key: ${{ secrets.LOCALIZE_APP_PRIVATE_KEY }}
owner: ${{ steps.parse.outputs.org }}
repositories: ${{ steps.parse.outputs.repo }}
- name: Checkout target repo
uses: actions/checkout@v4
with:
repository: ${{ steps.parse.outputs.org }}/${{ steps.parse.outputs.repo }}
ref: ${{ steps.parse.outputs.branch }}
token: ${{ steps.app-token.outputs.token }}
- name: Create branch and commit
id: commit
env:
FILE_PATH: ${{ steps.parse.outputs.file_path }}
LANG: ${{ steps.parse.outputs.lang }}
FILE_KEY: ${{ steps.parse.outputs.file_key }}
AUTHOR: ${{ steps.parse.outputs.author }}
CONTENT_B64: ${{ steps.parse.outputs.content_b64 }}
run: |
BRANCH_NAME="translate/${LANG}/${FILE_KEY//[^a-zA-Z0-9_.-]/_}-$(date +%s)"
git checkout -b "$BRANCH_NAME"
mkdir -p "$(dirname "$FILE_PATH")"
echo "$CONTENT_B64" | base64 -d > "$FILE_PATH"
git config user.name "ovos-localize[bot]"
git config user.email "ovos-localize[bot]@users.noreply.github.com"
git add "$FILE_PATH"
git commit -m "translate(${LANG}): update ${FILE_KEY}" -m "Submitted by @${AUTHOR} via OVOS Localize"
git push origin "$BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
- name: Create Pull Request
id: pr
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
PR_URL=$(gh pr create \
--repo "${{ steps.parse.outputs.org }}/${{ steps.parse.outputs.repo }}" \
--base "${{ steps.parse.outputs.branch }}" \
--head "${{ steps.commit.outputs.branch_name }}" \
--title "translate(${{ steps.parse.outputs.lang }}): update ${{ steps.parse.outputs.file_key }}" \
--body "## Translation update
- **Language**: \`${{ steps.parse.outputs.lang }}\`
- **File**: \`${{ steps.parse.outputs.file_path }}\`
- **Submitted by**: @${{ steps.parse.outputs.author }}
Submitted via [OVOS Localize](https://openvoiceos.github.io/ovos-localize/).
Triggered by #${{ github.event.issue.number }}.")
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
- name: Close issue with PR link
uses: actions/github-script@v7
with:
script: |
const prUrl = '${{ steps.pr.outputs.pr_url }}';
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `✅ **Translation PR created!**\n\n${prUrl}\n\nThe skill maintainer will review and merge it. Thank you for contributing!`
});
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
state: 'closed',
state_reason: 'completed'
});