Skip to content

Commit

Permalink
🚚 Prevent Weblate Update workflow from overwriting existing PR (hedyo…
Browse files Browse the repository at this point in the history
…rg#5397)

If an open Weblate/translations PR still exists, we shouldn't tell Weblate to push again.  Because we ended our previous push with a 'reset', Weblate would otherwise force-push new changes over the unmerged old changes, causing them to lost.

**How to test**

After merging:

* Reopen an old Weblate PR
* Run the "update weblate" workflow on-demand
* Observe that it errors out and doesn't overwrite the old PR with new changes.
  • Loading branch information
rix0rrr authored Apr 11, 2024
1 parent 616dc73 commit 749801a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion .github/workflows/update-weblate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ jobs:
runs-on: ubuntu-latest

steps:
# If an open Weblate/translations PR still exists, we shouldn't tell Weblate to push again.
# Because we ended our previous push with a 'reset', Weblate would otherwise force-push
# new changes over the unmerged old changes, causing them to lost.
- name: Check for existence of old Weblate PR
run: |
prs=$(gh pr -R hedyorg/hedy list -q '.[] | select(.title | contains("Translations update"))' --json title)
if [[ "$prs" != "" ]]; then
echo "Open Pull Request for Weblate!"
gh pr -R hedyorg/hedy list --search 'Translations update'
exit 1
fi
- name: Set up Python 3.12
uses: actions/setup-python@v1
with:
Expand All @@ -38,6 +49,10 @@ jobs:
wlc pull
wlc commit
wlc push
wlc reset
# On our repo, 'wlc reset' consistently times out the TCP connection after waiting
# for 5 minutes. The actual reset does seem to work, so we just don't wait for the
# command to finish, otherwise all our workflow executions show errors.
wlc reset &
sleep 10

0 comments on commit 749801a

Please sign in to comment.