Merge pull request #85 from dipamsen/master #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |