Skip to content

Merge translations

Merge translations #2

name: Merge translation PRs
on:
workflow_dispatch:
inputs:
repository:
description: "Merge Weblate PR in a specific repo or all"
required: true
default: "all"
type: choice
options:
- "all"
- "FossifyOrg/Calculator"
- "FossifyOrg/Calendar"
- "FossifyOrg/Camera"
- "FossifyOrg/Clock"
- "FossifyOrg/Contacts"
- "FossifyOrg/File-Manager"
- "FossifyOrg/Gallery"
- "FossifyOrg/Keyboard"
- "FossifyOrg/Launcher"
- "FossifyOrg/Messages"
- "FossifyOrg/Music-Player"
- "FossifyOrg/Notes"
- "FossifyOrg/Paint"
- "FossifyOrg/Phone"
- "FossifyOrg/Thank-You"
- "FossifyOrg/Voice-Recorder"
concurrency:
group: "merge-weblate-prs"
cancel-in-progress: true
jobs:
merge:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911
with:
egress-policy: audit
- name: Merge Weblate PRs
run: |
set -uo pipefail
declare -A WEBLATE_BRANCH=(
["FossifyOrg/Calculator"]="weblate-fossify-calculator"
["FossifyOrg/Calendar"]="weblate-fossify-calendar"
["FossifyOrg/Camera"]="weblate-fossify-camera"
["FossifyOrg/Clock"]="weblate-fossify-clock"
["FossifyOrg/Contacts"]="weblate-fossify-contacts"
["FossifyOrg/File-Manager"]="weblate-fossify-file-manager"
["FossifyOrg/Gallery"]="weblate-fossify-gallery"
["FossifyOrg/Keyboard"]="weblate-fossify-keyboard"
["FossifyOrg/Launcher"]="weblate-fossify-launcher"
["FossifyOrg/Messages"]="weblate-fossify-sms-messenger"
["FossifyOrg/Music-Player"]="weblate-fossify-music-player"
["FossifyOrg/Notes"]="weblate-fossify-notes"
["FossifyOrg/Paint"]="weblate-fossify-draw"
["FossifyOrg/Phone"]="weblate-fossify-phone"
["FossifyOrg/Thank-You"]="weblate-fossify-thank-you"
["FossifyOrg/Voice-Recorder"]="weblate-fossify-voice-recorder"
)
REPOS=(
"FossifyOrg/Calculator"
"FossifyOrg/Calendar"
"FossifyOrg/Camera"
"FossifyOrg/Clock"
"FossifyOrg/Contacts"
"FossifyOrg/File-Manager"
"FossifyOrg/Gallery"
"FossifyOrg/Keyboard"
"FossifyOrg/Launcher"
"FossifyOrg/Messages"
"FossifyOrg/Music-Player"
"FossifyOrg/Notes"
"FossifyOrg/Paint"
"FossifyOrg/Phone"
"FossifyOrg/Thank-You"
"FossifyOrg/Voice-Recorder"
)
SELECTED_REPO="${{ github.event.inputs.repository }}"
if [[ "$SELECTED_REPO" != "all" ]]; then
REPOS=("$SELECTED_REPO")
echo "Processing single repository: $SELECTED_REPO"
else
echo "Processing all repositories (${#REPOS[@]} repos)"
fi
for repo in "${REPOS[@]}"; do
echo "Processing: $repo"
BRANCH="${WEBLATE_BRANCH[$repo]:-}"
if [[ -z "$BRANCH" ]]; then
echo "[$repo]: No mapped Weblate branch. Skipping."
continue
fi
PR_NUMBER=$(gh pr list --repo "$repo" --head "$BRANCH" --search "author:weblate" --json number --jq '.[0].number // empty' 2>/dev/null)
if [[ -z "$PR_NUMBER" ]]; then
echo "[$repo]: No open PR found for head $BRANCH. Skipping."
continue
fi
echo "[$repo]: Found PR #$PR_NUMBER for head $BRANCH"
if gh pr review --repo "$repo" --approve "$PR_NUMBER" 2>/dev/null; then
echo "[$repo]: PR #$PR_NUMBER approved"
else
echo "[$repo]: Failed to approve PR #$PR_NUMBER"
fi
# rebase merge so individual commits are preserved
if gh pr merge --repo "$repo" --rebase "$PR_NUMBER" 2>/dev/null; then
echo "[$repo]: PR #$PR_NUMBER merged successfully"
else
echo "[$repo]: Failed to merge PR #$PR_NUMBER. Skipping."
fi
sleep 1
done
echo "Done processing all repositories."