Skip to content

Push changes to pull request HEAD #13

Push changes to pull request HEAD

Push changes to pull request HEAD #13

Workflow file for this run

name: Push changes to pull request HEAD
on:
workflow_run:
workflows: [Import translations from Weblate]
types: [completed]
jobs:
check-for-changes:
runs-on: ubuntu-20.04
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
outputs:
is-patch-empty: ${{ steps.check-patch.outputs.is-empty }}
steps:
- name: Download the pull request run's artifact
uses: actions/download-artifact@v4
with:
name: sync-translations-data
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Check if the patch contains any changes
id: check-patch
run: |
if [ -s sync-translations.patch ]
then
echo "Patch is not empty"
echo "is-empty=0" >> "$GITHUB_OUTPUT"
else
echo "Patch is empty"
echo "is-empty=1" >> "$GITHUB_OUTPUT"
fi
apply-patch:
runs-on: ubuntu-20.04
needs: [check-for-changes]
if: needs.check-for-changes.outputs.is-patch-empty == 0
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download the pull request run's artifact
uses: actions/download-artifact@v4
with:
name: sync-translations-data
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Checkout the pull request's HEAD
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
. git_vars.sh
git remote add other "$PR_HEAD_URL"
git fetch other
git checkout "$PR_HEAD_REF"
git status
- name: Apply the patch
run: git apply sync-translations.patch
- name: Commit and push changes
run: |
. git_vars.sh
rm git_vars.sh sync-translations.patch
git add .
git commit -m "$COMMIT_MESSAGE"
git push