-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
75 lines (62 loc) · 2.04 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: i18n.site
description: 'https://i18n.site'
inputs:
I18N_SITE_TOKEN:
description: 'https://i18n.site/token'
required: true
default: ''
NPM_TOKEN:
description: 'https://docs.npmjs.org/about-access-tokens'
required: true
default: ''
workdir:
description: 'working directory (default is the repository root)'
required: false
default: ''
default_branch:
description: 'default branch ( default is "main" )'
required: false
default: 'main'
runs:
using: 'composite'
steps:
- name: i18n.site
shell: bash
run: |
set -ex
workdir="${{ inputs.workdir }}"
if [ -z "$workdir" ]; then
workdir="$(pwd)"
else
workdir="$(realpath "$workdir")"
fi
tmp=$(mktemp -d)
cd $tmp
git clone https://github.com/i18n-site/github-action-i18n.site.git .
mkdir -p /opt
cd /opt
$tmp/setup.sh i18n.site
cd $workdir
echo "//registry.npmjs.org/:_authToken=${{ inputs.NPM_TOKEN }}" > ~/.npmrc
branch=$(git rev-parse --abbrev-ref HEAD)
I18N_SITE_TOKEN="${{ inputs.I18N_SITE_TOKEN }}" \
/opt/bin/i18n.site -n \
$([ -f ".i18n/htm/${branch}.package.json" ] && echo "-c $branch" || echo "")
if [[ -n $(git status -s) ]]; then
git config --global user.name "i18n.site"
git config --global user.email "[email protected]"
git add .
git commit -m 'https://i18n.site'
repo=https://x-access-token:${{github.token}}@github.com/${{ github.repository }}
git push $repo HEAD:${{ github.ref }}
default_branch=${{ inputs.default_branch }}
if [[ "$branch" != "$default_branch" ]]; then
git fetch --unshallow
git fetch origin $default_branch
git merge origin/$default_branch --no-edit
git commit -m"merge $branch" || true
git push $repo $branch:$default_branch || true
fi
else
echo "NO CHANGE"
fi