-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (96 loc) · 3.72 KB
/
translate-and-build-package.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Translate and Build Package
on:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "With TMATE"
required: false
default: false
push:
branches: ["*"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: If Template exit
shell: bash
run: |
cancel () {
echo "Pacote de template, não precisa traduzir e compilar"
echo "SAINDO...."
curl -s -H "Authorization: token ${{ github.token }}" \
-X POST "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel"
sleep infinity
}
if [ -n "$(grep biglinux-package-template pkgbuild/PKGBUILD)" ];then
cancel
fi
- name: Install Translator Dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install \
git \
gettext \
npm
# Install attranslator
sudo npm install --location=global attranslate
## Tmate ##
- name: Setup TMATE Session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
# - name: Translate Package
# shell: bash #-O extglob {0}
# env:
# AZURE_KEY: ${{ secrets.AZURE_KEY }}
# OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
# run: |
# cd ..
# git clone https://github.com/biglinux/big-auto-translator.git
# mv big-auto-translator/gettext_po_generator_github.sh .
# sudo cp -f big-auto-translator/openai-translate.js /usr/local/lib/node_modules/attranslate/dist/services/openai-translate.js
# gitfolder=$(echo ${{ github.repository }} | rev | cut -d "/" -f1 | rev)
# # export OriginalLang=pt-BR
# bash gettext_po_generator_github.sh $gitfolder
- name: Update github
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add --all
if [ -n "$(git commit -m "github-actions bot Translate $(date +%y-%m-%d_%H:%M)" -a | grep "nothing to commit")" ];then exit 0; fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.REPOSITORY_TOKEN }}
branch: ${{ github.ref }}
- name: Build Package on build-package
shell: bash
run: |
repo_name=${{ github.repository }}
IFS='/' read -r owner repo <<< "$repo_name"
# Define a variável data
data="{\
\"event_type\": \"$repo\", \
\"client_payload\": { \
\"branch\": \"${{ github.ref_name }}\", \
\"branch_type\": \"testing\", \
\"url\": \"https://github.com/${{ github.repository }}\" \
}\
}"
# Executa o comando curl com a variável data
response=$(curl -s -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.REPOSITORY_TOKEN }}" \
--data "$data" \
-w "%{http_code}" \
-o /dev/null \
"https://api.github.com/repos/chililinux/build-package/dispatches")
echo "Response: $response"
if [[ "$response" != "204" ]]; then
echo "$response: Falha ao acionar o workflow de build '${{ github.repository }}'"
exit 1
else
echo "$response: Workflow de build '${{ github.repository }}' acionado com sucesso."
fi