-
Notifications
You must be signed in to change notification settings - Fork 26
70 lines (60 loc) · 2.32 KB
/
update-data.yaml
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
name: Update data
on:
workflow_dispatch:
# push:
# branches:
# - 'master'
# paths:
# - ".github/workflows/update-data.yaml"
# - "wimp/**"
# - "main.py"
# - "requirements.txt"
jobs:
main:
name: Generate and push latest data
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Configure python
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install Requirements
run: pip install --no-cache-dir -r requirements.txt
- name: Configure Credentials
env:
ERPCREDS: ${{ secrets.ERPCREDS }}
GMAIL_TOKEN: ${{ secrets.GMAIL_TOKEN }}
run: |
echo "$ERPCREDS" > erpcreds.py
echo "$GMAIL_TOKEN" > wimp/token.json
- name: Run the script
run: python main.py auto
- name: Configure SSH key
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/metakgp-service
echo "$SSH_PUBLIC_KEY" > ~/.ssh/metakgp-service.pub
chmod 600 ~/.ssh/metakgp-service
chmod 600 ~/.ssh/metakgp-service.pub
- name: Configure git
run: |
git config user.email "[email protected]"
git config user.name "metakgp-service"
git config gpg.format ssh
git config user.signingkey ~/.ssh/metakgp-service.pub
- name: Commit & push changes
env:
SSH_KEY_PASSPHRASE: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
run: |
if [ -n "$(git status --porcelain data/)" ]; then
git add data/
git commit -S -m "chore(data): updated data files" <<< "$SSH_KEY_PASSPHRASE"
git push origin $(git rev-parse --abbrev-ref HEAD)
else
echo "No changes in data/"
fi