garmin-sync-coros #970
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: garmin-sync-coros | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0,6,19 * * ?' | |
env: | |
GITHUB_NAME: XiaoSiHwang | |
GITHUB_EMAIL: [email protected] | |
## 佳明配置 | |
GARMIN_AUTH_DOMAIN: ${{ secrets.GARMIN_AUTH_DOMAIN }} | |
GARMIN_EMAIL: ${{ secrets.GARMIN_EMAIL }} | |
GARMIN_PASSWORD: ${{ secrets.GARMIN_PASSWORD }} | |
## Coros配置 | |
COROS_EMAIL: ${{ secrets.COROS_EMAIL }} | |
COROS_PASSWORD: ${{ secrets.COROS_PASSWORD }} | |
### 按需选择,如果选择 garmin_to_coros 佳明同步高驰 | |
### 如果选择 coros_to_garmin 高驰同步佳明 | |
RUN_TYPE: garmin_to_coros # garmin_to_coros 佳明同步高驰、 coros_to_garmin | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
# from pdm | |
- name: Set Variables | |
id: set_variables | |
run: | | |
echo "::set-output name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" | |
echo "::set-output name=PIP_CACHE::$(pip cache dir)" | |
- name: Cache PIP | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.set_variables.outputs.PIP_CACHE }} | |
key: Ubuntu-pip-${{ steps.set_variables.outputs.PY }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
if: steps.pip-cache.outputs.cache-hit != 'true' | |
- name: Run Garmin Sync Coros | |
if: env.RUN_TYPE == 'garmin_to_coros' | |
run: | | |
python scripts/garmin/garmin_sync_coros.py | |
- name: Run Coros Sync Garmin | |
if: env.RUN_TYPE == 'coros_to_garmin' | |
run: | | |
python scripts/coros/coros_sync_garmin.py | |
- name: Push new cookie | |
run: | | |
git config --local user.email "${{ env.GITHUB_EMAIL }}" | |
git config --local user.name "${{ env.GITHUB_NAME }}" | |
git add . | |
git commit -m 'faet(sync): new upload activity' || echo "nothing to commit" | |
git push || echo "nothing to push" |