fix: using session to download keep route #1599
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: Run Data Sync | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' | |
push: | |
branches: | |
- master | |
paths: | |
- scripts/nike_sync.py | |
- scripts/nike_to_strava_sync.py | |
- scripts/strava_sync.py | |
- scripts/gen_svg.py | |
- scripts/garmin_sync.py | |
- scripts/keep_sync.py | |
- scripts/gpx_sync.py | |
- scripts/tcx_sync.py | |
- scripts/garmin_to_strava_sync.py | |
- requirements.txt | |
env: | |
# please change to your own config. | |
RUN_TYPE: pass # support strava/nike/garmin/garmin_cn/keep/only_gpx/only_fit/nike_to_strava/strava_to_garmin/strava_to_garmin_cn/garmin_to_strava/garmin_to_strava_cn/codoon, Please change the 'pass' it to your own | |
ATHLETE: yihong0618 | |
TITLE: Yihong0618 Running | |
MIN_GRID_DISTANCE: 10 # change min distance here | |
TITLE_GRID: Over 10km Runs # also here | |
GITHUB_NAME: yihong0618 # change to yours | |
GITHUB_EMAIL: [email protected] # change to yours | |
# IGNORE_BEFORE_SAVING: True # if you want to ignore some data before saving, set this to True | |
IGNORE_START_END_RANGE: 10 # Unit meter | |
# Dont making this huge, just picking points you needing. https://developers.google.com/maps/documentation/utilities/polylineutility using this tool to making your polyline | |
IGNORE_POLYLINE: "ktjrFoemeU~IorGq}DeB" | |
IGNORE_RANGE: 10 # Unit meter | |
SAVE_DATA_IN_GITHUB_CACHE: false # if you deploy in the vercal, check the README | |
DATA_CACHE_PREFIX: "track_data" | |
BUILD_GH_PAGES: true # If you do not need GitHub Page please set it to `false` | |
jobs: | |
sync: | |
name: Sync | |
runs-on: ubuntu-latest | |
outputs: | |
SAVE_DATA_IN_GITHUB_CACHE: ${{ steps.set_output.outputs.SAVE_DATA_IN_GITHUB_CACHE }} | |
DATA_CACHE_PREFIX: ${{ steps.set_output.outputs.DATA_CACHE_PREFIX }} | |
BUILD_GH_PAGES: ${{ steps.set_output.outputs.BUILD_GH_PAGES }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
id: setup_python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
cache: pip | |
cache-dependency-path: 'requirements.txt' | |
- name: Install dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Cache Data Files | |
if: env.SAVE_DATA_IN_GITHUB_CACHE == 'true' | |
uses: actions/cache@v3 | |
with: | |
path: | | |
activities | |
assets | |
GPX_OUT | |
TCX_OUT | |
FIT_OUT | |
Workouts | |
scripts/data.db | |
src/static/activities.json | |
imported.json | |
key: ${{ env.DATA_CACHE_PREFIX }}-${{ github.sha }}-${{ github.run_id }} | |
restore-keys: | | |
${{ env.DATA_CACHE_PREFIX }}-${{ github.sha }}- | |
${{ env.DATA_CACHE_PREFIX }}- | |
- name: Run sync Nike script | |
if: env.RUN_TYPE == 'nike' | |
run: | | |
python scripts/nike_sync.py ${{ secrets.NIKE_REFRESH_TOKEN }} | |
- name: Run sync Nike to Strava(Run with nike data backup and show with strava) | |
if: env.RUN_TYPE == 'nike_to_strava' | |
run: | | |
python scripts/nike_to_strava_sync.py ${{ secrets.NIKE_REFRESH_TOKEN }} ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} | |
- name: Run sync Keep script | |
if: env.RUN_TYPE == 'keep' | |
run: | | |
python scripts/keep_sync.py ${{ secrets.KEEP_MOBILE }} ${{ secrets.KEEP_PASSWORD }} --with-gpx | |
- name: Run sync Strava script | |
if: env.RUN_TYPE == 'strava' | |
run: | | |
python scripts/strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} | |
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs). | |
# python scripts/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run --is-cn | |
- name: Run sync Codoon script | |
if: env.RUN_TYPE == 'codoon' | |
run: | | |
python scripts/codoon_sync.py ${{ secrets.CODOON_MOBILE }} ${{ secrets.CODOON_PASSWORD }} | |
# for garmin if you want generate `tcx` you can add --tcx command in the args. | |
- name: Run sync Garmin script | |
if: env.RUN_TYPE == 'garmin' | |
run: | | |
python scripts/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} | |
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs). | |
# python scripts/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run | |
- name: Run sync Garmin CN script | |
if: env.RUN_TYPE == 'garmin_cn' | |
run: | | |
python scripts/garmin_sync.py ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} --is-cn | |
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs). | |
# python scripts/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run --is-cn | |
- name: Run sync Only GPX script | |
if: env.RUN_TYPE == 'only_gpx' | |
run: | | |
python scripts/gpx_sync.py | |
- name: Run sync Only FIT script | |
if: env.RUN_TYPE == 'only_fit' | |
run: | | |
python scripts/fit_sync.py | |
- name: Run sync Only TCX script | |
if: env.RUN_TYPE == 'only_tcx' | |
run: | | |
python scripts/tcx_sync.py | |
- name: Run sync Strava to Garmin(Run with strava(or others upload to strava) data backup in Garmin) | |
if: env.RUN_TYPE == 'strava_to_garmin' | |
run: | | |
python scripts/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} | |
- name: Run sync Strava to Garmin-cn(Run with strava(or others upload to strava) data backup in Garmin-cn) | |
if: env.RUN_TYPE == 'strava_to_garmin_cn' | |
run: | | |
python scripts/strava_to_garmin_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} ${{ secrets.STRAVA_EMAIL }} ${{ secrets.STRAVA_PASSWORD }} --is-cn | |
- name: Run sync Garmin-cn to Strava(Run with Garmin data backup in Strava) | |
if: env.RUN_TYPE == 'garmin_to_strava_cn' | |
run: | | |
python scripts/garmin_to_strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_CN_EMAIL }} ${{ secrets.GARMIN_CN_PASSWORD }} --is-cn | |
- name: Run sync Garmin to Strava(Run with Garmin data backup in Strava) | |
if: env.RUN_TYPE == 'garmin_to_strava' | |
run: | | |
python scripts/garmin_to_strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }} ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} | |
- name: Run sync Tulipsport script | |
if: env.RUN_TYPE == 'tulipsport' | |
run: | | |
python scripts/tulipsport_sync.py ${{ secrets.TULIPSPORT_TOKEN }} --with-gpx | |
- name: Make svg GitHub profile | |
if: env.RUN_TYPE != 'pass' | |
run: | | |
python scripts/gen_svg.py --from-db --title "${{ env.TITLE }}" --type github --athlete "${{ env.ATHLETE }}" --special-distance 10 --special-distance2 20 --special-color yellow --special-color2 red --output assets/github.svg --use-localtime --min-distance 0.5 | |
python scripts/gen_svg.py --from-db --title "${{ env.TITLE_GRID }}" --type grid --athlete "${{ env.ATHLETE }}" --output assets/grid.svg --special-color yellow --special-color2 red --special-distance 20 --special-distance2 40 --use-localtime --min-distance "${{ env.MIN_GRID_DISTANCE }}" | |
python scripts/gen_svg.py --from-db --type circular --use-localtime | |
python scripts/gen_svg.py --from-db --year $(date +"%Y") --language zh_CN --title "$(date +"%Y") Running" --type github --athlete "${{ env.ATHLETE }}" --special-distance 10 --special-distance2 20 --special-color yellow --special-color2 red --output assets/github_$(date +"%Y").svg --use-localtime --min-distance 0.5 | |
- name: Push new runs | |
if: env.SAVE_DATA_IN_GITHUB_CACHE != 'true' | |
run: | | |
git config --local user.email "${{ env.GITHUB_EMAIL }}" | |
git config --local user.name "${{ env.GITHUB_NAME }}" | |
git add . | |
git commit -m 'update new runs' || echo "nothing to commit" | |
git push || echo "nothing to push" | |
- name: Set Output | |
id: set_output | |
run: | | |
echo "SAVE_DATA_IN_GITHUB_CACHE=${{ env.SAVE_DATA_IN_GITHUB_CACHE }}" >> "$GITHUB_OUTPUT" | |
echo "DATA_CACHE_PREFIX=${{ env.DATA_CACHE_PREFIX }}" >> "$GITHUB_OUTPUT" | |
echo "BUILD_GH_PAGES=${{ env.BUILD_GH_PAGES }}" >> "$GITHUB_OUTPUT" | |
publish_github_pages: | |
if: needs.sync.result == 'success' && needs.sync.outputs.BUILD_GH_PAGES == 'true' | |
name: Build and publish Github Pages | |
uses: ./.github/workflows/gh-pages.yml | |
with: | |
save_data_in_github_cache: ${{needs.sync.outputs.SAVE_DATA_IN_GITHUB_CACHE == 'true'}} | |
data_cache_prefix: ${{needs.sync.outputs.DATA_CACHE_PREFIX}} | |
needs: | |
- sync |