3 on: [push, pull_request_target]
5 # Avoid unnecessary builds. Unlike the main CI jobs, these are not
6 # ci-configurable (but could be).
8 group: ${{ github.workflow }}-${{ github.ref }}
9 cancel-in-progress: true
14 endsWith(github.repository, '/git-po') ||
15 contains(github.head_ref, 'l10n') ||
16 contains(github.ref, 'l10n')
17 runs-on: ubuntu-latest
21 - name: Setup base and head objects
24 if test "${{ github.event_name }}" = "pull_request_target"
26 base=${{ github.event.pull_request.base.sha }}
27 head=${{ github.event.pull_request.head.sha }}
29 base=${{ github.event.before }}
30 head=${{ github.event.after }}
32 echo base=$base >>$GITHUB_OUTPUT
33 echo head=$head >>$GITHUB_OUTPUT
34 - name: Run partial clone
36 git -c init.defaultBranch=master init --bare .
40 https://github.com/${{ github.repository }}
41 # Fetch tips that may be unreachable from github.ref:
42 # - For a forced push, "$base" may be unreachable.
43 # - For a "pull_request_target" event, "$head" may be unreachable.
46 ${{ steps.setup-tips.outputs.base }} \
47 ${{ steps.setup-tips.outputs.head }}
54 # Should not fetch ZERO-OID.
58 git -c protocol.version=2 fetch \
61 --no-write-fetch-head \
66 - uses: actions/setup-go@v2
69 - name: Install git-po-helper
70 run: go install github.com/git-l10n/git-po-helper@main
71 - name: Install other dependencies
73 sudo apt-get update -q &&
74 sudo apt-get install -q -y gettext
75 - name: Run git-po-helper
79 git-po-helper check-commits \
80 --github-action-event="${{ github.event_name }}" -- \
81 ${{ steps.setup-tips.outputs.base }}..${{ steps.setup-tips.outputs.head }} \
82 >git-po-helper.out 2>&1 || exit_code=$?
83 if test $exit_code -ne 0 || grep -q WARNING git-po-helper.out
85 # Remove ANSI colors which are proper for console logs but not
86 # proper for PR comment.
87 echo "COMMENT_BODY<<EOF" >>$GITHUB_ENV
88 perl -pe 's/\e\[[0-9;]*m//g; s/\bEOF$//g' git-po-helper.out >>$GITHUB_ENV
89 echo "EOF" >>$GITHUB_ENV
93 - name: Create comment in pull request for report
94 uses: mshick/add-pr-comment@v1
97 github.event_name == 'pull_request_target' &&
98 env.COMMENT_BODY != ''
100 repo-token: ${{ secrets.GITHUB_TOKEN }}
101 repo-token-user-login: 'github-actions[bot]'
103 ${{ steps.check-commits.outcome == 'failure' && 'Errors and warnings' || 'Warnings' }}
104 found by [git-po-helper](https://github.com/git-l10n/git-po-helper#readme) in workflow
105 [#${{ github.run_number }}](${{ env.GITHUB_SERVER_URL }}/${{ github.repository }}/actions/runs/${{ github.run_id }}):
109 ${{ env.COMMENT_BODY }}