Skip to content

Commit df9c83b

Browse files
committed
Merge branch 'jx/ci-l10n'
CI help for l10n. * jx/ci-l10n: ci: new github-action for git-l10n code review
2 parents ac162a6 + a788d31 commit df9c83b

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

.github/workflows/l10n.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: git-l10n
2+
3+
on: [push, pull_request_target]
4+
5+
jobs:
6+
git-po-helper:
7+
if: >-
8+
endsWith(github.repository, '/git-po') ||
9+
contains(github.head_ref, 'l10n') ||
10+
contains(github.ref, 'l10n')
11+
runs-on: ubuntu-latest
12+
permissions:
13+
pull-requests: write
14+
steps:
15+
- name: Setup base and head objects
16+
id: setup-tips
17+
run: |
18+
if test "${{ github.event_name }}" = "pull_request_target"
19+
then
20+
base=${{ github.event.pull_request.base.sha }}
21+
head=${{ github.event.pull_request.head.sha }}
22+
else
23+
base=${{ github.event.before }}
24+
head=${{ github.event.after }}
25+
fi
26+
echo "::set-output name=base::$base"
27+
echo "::set-output name=head::$head"
28+
- name: Run partial clone
29+
run: |
30+
git -c init.defaultBranch=master init --bare .
31+
git remote add \
32+
--mirror=fetch \
33+
origin \
34+
https://github.com/${{ github.repository }}
35+
# Fetch tips that may be unreachable from github.ref:
36+
# - For a forced push, "$base" may be unreachable.
37+
# - For a "pull_request_target" event, "$head" may be unreachable.
38+
args=
39+
for commit in \
40+
${{ steps.setup-tips.outputs.base }} \
41+
${{ steps.setup-tips.outputs.head }}
42+
do
43+
case $commit in
44+
*[^0]*)
45+
args="$args $commit"
46+
;;
47+
*)
48+
# Should not fetch ZERO-OID.
49+
;;
50+
esac
51+
done
52+
git -c protocol.version=2 fetch \
53+
--progress \
54+
--no-tags \
55+
--no-write-fetch-head \
56+
--filter=blob:none \
57+
origin \
58+
${{ github.ref }} \
59+
$args
60+
- uses: actions/setup-go@v2
61+
with:
62+
go-version: '>=1.16'
63+
- name: Install git-po-helper
64+
run: go install github.com/git-l10n/git-po-helper@main
65+
- name: Install other dependencies
66+
run: |
67+
sudo apt-get update -q &&
68+
sudo apt-get install -q -y gettext
69+
- name: Run git-po-helper
70+
id: check-commits
71+
run: |
72+
exit_code=0
73+
git-po-helper check-commits \
74+
--github-action-event="${{ github.event_name }}" -- \
75+
${{ steps.setup-tips.outputs.base }}..${{ steps.setup-tips.outputs.head }} \
76+
>git-po-helper.out 2>&1 || exit_code=$?
77+
if test $exit_code -ne 0 || grep -q WARNING git-po-helper.out
78+
then
79+
# Remove ANSI colors which are proper for console logs but not
80+
# proper for PR comment.
81+
echo "COMMENT_BODY<<EOF" >>$GITHUB_ENV
82+
perl -pe 's/\e\[[0-9;]*m//g; s/\bEOF$//g' git-po-helper.out >>$GITHUB_ENV
83+
echo "EOF" >>$GITHUB_ENV
84+
fi
85+
cat git-po-helper.out
86+
exit $exit_code
87+
- name: Create comment in pull request for report
88+
uses: mshick/add-pr-comment@v1
89+
if: >-
90+
always() &&
91+
github.event_name == 'pull_request_target' &&
92+
env.COMMENT_BODY != ''
93+
with:
94+
repo-token: ${{ secrets.GITHUB_TOKEN }}
95+
repo-token-user-login: 'github-actions[bot]'
96+
message: >
97+
${{ steps.check-commits.outcome == 'failure' && 'Errors and warnings' || 'Warnings' }}
98+
found by [git-po-helper](https://github.com/git-l10n/git-po-helper#readme) in workflow
99+
[#${{ github.run_number }}](${{ env.GITHUB_SERVER_URL }}/${{ github.repository }}/actions/runs/${{ github.run_id }}):
100+
101+
```
102+
103+
${{ env.COMMENT_BODY }}
104+
105+
```

0 commit comments

Comments
 (0)