|
| 1 | +name: Update translated manual pages |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + force-rebuild: |
| 7 | + description: Force re-building all manual pages (e.g. after a script change) |
| 8 | + type: boolean |
| 9 | + default: false |
| 10 | + schedule: |
| 11 | + # check daily for updates |
| 12 | + - cron: '41 19 * * *' |
| 13 | + |
| 14 | +jobs: |
| 15 | + check-for-updates: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + sparse-checkout: | |
| 21 | + external/docs/sync |
| 22 | + script |
| 23 | + - uses: actions/github-script@v7 |
| 24 | + id: get-pending |
| 25 | + with: |
| 26 | + script: | |
| 27 | + const { areTranslatedManualPagesUpToDate } = require('./script/ci-helper.js') |
| 28 | +
|
| 29 | + return await areTranslatedManualPagesUpToDate(github) |
| 30 | + outputs: |
| 31 | + up-to-date: ${{ steps.get-pending.outputs.result }} |
| 32 | + update-translated-manual-pages: |
| 33 | + needs: [check-for-updates] |
| 34 | + if: inputs.force-rebuild == true || needs.check-for-updates.outputs.up-to-date == 'false' |
| 35 | + runs-on: ubuntu-latest |
| 36 | + permissions: |
| 37 | + contents: write # to push changes (if any) |
| 38 | + pages: write # to deploy to GitHub Pages |
| 39 | + id-token: write # to verify that the deployment source is legit |
| 40 | + environment: |
| 41 | + name: github-pages |
| 42 | + url: ${{ steps.deploy.outputs.url }} |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + - name: ruby setup |
| 46 | + uses: ruby/setup-ruby@v1 |
| 47 | + with: |
| 48 | + bundler-cache: true |
| 49 | + - name: clone jnavila/git-html-l10n |
| 50 | + run: git clone --bare https://github.com/jnavila/git-html-l10n '${{ runner.temp }}/git-html-l10n' |
| 51 | + - name: update translated manual pages |
| 52 | + run: | |
| 53 | + if test true = '${{ inputs.force-rebuild }}' |
| 54 | + then |
| 55 | + export RERUN=true |
| 56 | + fi |
| 57 | + bundle exec ruby script/update-docs.rb '${{ runner.temp }}/git-html-l10n' l10n |
| 58 | + - name: commit translated manual pages |
| 59 | + id: manual-pages |
| 60 | + run: | |
| 61 | + mkdir -p external/docs/sync && |
| 62 | + git -C '${{ runner.temp }}/git-html-l10n' rev-parse HEAD >external/docs/sync/git-html-l10n.sha && |
| 63 | + git add external/docs/sync/git-html-l10n.sha && |
| 64 | +
|
| 65 | + git add -A external/docs && |
| 66 | + if test true = '${{ inputs.force-rebuild }}' && git diff-index --cached --quiet HEAD -- |
| 67 | + then |
| 68 | + echo '::notice::Rebuild of the translated manual pages was requested but resulted in no changes' >&2 |
| 69 | + exit 0 |
| 70 | + fi && |
| 71 | + git \ |
| 72 | + -c user.name=${{ github.actor }} \ |
| 73 | + -c user.email=${{ github.actor }}@noreply.github.com \ |
| 74 | + commit -m "Update translated manual pages" \ |
| 75 | + -m 'Updated via the `update-translated-manual-pages.yml` GitHub workflow.' && |
| 76 | + echo "result=modified" >>$GITHUB_OUTPUT |
| 77 | + - name: verify that there are no uncommitted changes |
| 78 | + run: | |
| 79 | + git update-index --refresh && |
| 80 | + if test -n "$(git diff HEAD)$(git ls-files --exclude-standard --other)" |
| 81 | + then |
| 82 | + echo '::error::there are uncommitted changes!' >&2 |
| 83 | + git status >&2 |
| 84 | + exit 1 |
| 85 | + fi |
| 86 | + - name: deploy to GitHub Pages |
| 87 | + if: steps.manual-pages.outputs.result != '' |
| 88 | + id: deploy |
| 89 | + uses: ./.github/actions/deploy-to-github-pages |
0 commit comments