Skip to content

Sync inventory

Sync inventory #3

Workflow file for this run

name: Sync inventory
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * 0'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install mysql-to-sqlite3
- name: Get inventory data
run: mysql2sqlite -f inventory.db -d ${{ secrets.INVENTORY_DB }} -u ${{ secrets.INVENTORY_USER }} --mysql-password ${{ secrets.INVENTORY_PASSWORD }} -h ${{ secrets.INVENTORY_HOST }}
- name: Commit Files
run: |
git config --local user.email "${{ vars.GIT_EMAIL }}"
git config --local user.name "${{ vars.GIT_USER }}"
git add -A
git diff-index --quiet HEAD || (git commit -a -m "Sync inventory" --allow-empty)
- name: Push Changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Upload inventory.db
uses: bayssmekanique/action-simple-file-upload@v2
with:
user: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASSWORD }}
host: ${{ secrets.FTP_HOST }}
src: inventory.db
dest: inventory.db