Skip to content

Commit

Permalink
Merge branch 'refs/heads/upstream'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/run_data_sync.yml
  • Loading branch information
ben-29 committed Feb 11, 2025
2 parents eb81206 + 1f7643b commit 280f339
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ jobs:
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
id: setup_python
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ on:
type: string
default: track_data

permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: 'pages'
Expand All @@ -43,8 +38,9 @@ jobs:
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pages: write
id-token: write

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -53,6 +49,8 @@ jobs:
with:
# if your default branches is not master, please change it here
ref: master
fetch-depth: 0
persist-credentials: false

- name: Cache Data Files
if: inputs.save_data_in_github_cache
Expand Down Expand Up @@ -96,7 +94,9 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Build
run: PATH_PREFIX=/${{ github.event.repository.name }} pnpm build
env:
REPO_NAME: ${{ github.event.repository.name }}
run: PATH_PREFIX=/$REPO_NAME pnpm build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down
29 changes: 21 additions & 8 deletions .github/workflows/run_data_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Set up Python
id: setup_python
Expand Down Expand Up @@ -132,15 +135,15 @@ jobs:
- name: Run sync Garmin script
if: env.RUN_TYPE == 'garmin'
run: |
# python run_page/get_garmin_secret.py ${secrets.GARMIN_EMAIL} ${secrets.GARMIN_PASSWORD}
# make garimin secret string `python run_page/get_garmin_secret.py ${email} ${password}
python run_page/garmin_sync.py ${{ secrets.GARMIN_SECRET_STRING }}
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs).
# python run_page/garmin_sync.py ${{ secrets.GARMIN_SECRET_STRING }} --only-run

- name: Run sync Garmin CN script
if: env.RUN_TYPE == 'garmin_cn'
run: |
# python run_page/get_garmin_secret.py ${secrets.GARMIN_CN_EMAIL} ${secrets.GARMIN_CN_PASSWORD} --is-cn
# make garimin secret string `python run_page/get_garmin_secret.py ${email} ${password} --is-cn
python run_page/garmin_sync.py ${{ secrets.GARMIN_SECRET_STRING_CN }} --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 run_page/garmin_sync.py ${{ secrets.GARMIN_SECRET_STRING_CN }} --only-run --is-cn
Expand Down Expand Up @@ -208,15 +211,21 @@ jobs:
- name: Make svg GitHub profile
if: env.RUN_TYPE != 'pass'
env:
TITLE: ${{ env.TITLE }}
TITLE_GRID: ${{ env.TITLE_GRID }}
ATHLETE: ${{ env.ATHLETE }}
MIN_GRID_DISTANCE: ${{ env.MIN_GRID_DISTANCE }}
run: |
python run_page/gen_svg.py --from-db --title "${{ env.TITLE }}" --type github --github-style "align-firstday" --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 run_page/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 run_page/gen_svg.py --from-db --title "$TITLE" --type github --github-style "align-firstday" --athlete "$ATHLETE" --special-distance 10 --special-distance2 20 --special-color yellow --special-color2 red --output assets/github.svg --use-localtime --min-distance 0.5
python run_page/gen_svg.py --from-db --title "$TITLE_GRID" --type grid --athlete "$ATHLETE" --output assets/grid.svg --special-color yellow --special-color2 red --special-distance 20 --special-distance2 40 --use-localtime --min-distance "$MIN_GRID_DISTANCE"
python run_page/gen_svg.py --from-db --type circular --use-localtime
python run_page/gen_svg.py --from-db --year $(date +"%Y") --language zh_CN --title "$(date +"%Y") Workouts" --type github --github-style "align-firstday" --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
python run_page/gen_svg.py --from-db --year $(date +"%Y") --language zh_CN --title "$(date +"%Y") Workouts" --type github --github-style "align-firstday" --athlete "$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
# if you want use the style:the start day of each year always aligns with Monday. please use the following script:
# python run_page/gen_svg.py --from-db --title "${{ env.TITLE }}" --type github --github-style "align-monday" --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 run_page/gen_svg.py --from-db --year $(date +"%Y") --language zh_CN --title "$(date +"%Y") Running" --type github --github-style "align-monday" --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: Save data to parqent
if: env.SAVE_TO_PARQENT == 'true'
run: |
Expand All @@ -234,10 +243,14 @@ jobs:
- name: Set Output
id: set_output
env:
SAVE_DATA_IN_GITHUB_CACHE: ${{ env.SAVE_DATA_IN_GITHUB_CACHE }}
DATA_CACHE_PREFIX: ${{ env.DATA_CACHE_PREFIX }}
BUILD_GH_PAGES: ${{ env.BUILD_GH_PAGES }}
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"
echo "SAVE_DATA_IN_GITHUB_CACHE=$SAVE_DATA_IN_GITHUB_CACHE" >> "$GITHUB_OUTPUT"
echo "DATA_CACHE_PREFIX=$DATA_CACHE_PREFIX" >> "$GITHUB_OUTPUT"
echo "BUILD_GH_PAGES=$BUILD_GH_PAGES" >> "$GITHUB_OUTPUT"
publish_github_pages:
if: needs.sync.result == 'success' && needs.sync.outputs.BUILD_GH_PAGES == 'true'
Expand Down
9 changes: 6 additions & 3 deletions run_page/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ def make_activities_file(
with open(json_file, "w") as f:
json.dump(activities_list, f, indent=0)


def make_activities_file_only(sql_file, data_dir, json_file, file_suffix="gpx"):
def make_activities_file_only(
sql_file, data_dir, json_file, file_suffix="gpx", activity_title_dict={}
):
generator = Generator(sql_file)
generator.sync_from_data_dir(data_dir, file_suffix=file_suffix)
generator.sync_from_data_dir(
data_dir, file_suffix=file_suffix, activity_title_dict=activity_title_dict
)
activities_list = generator.loadForMapping()
with open(json_file, "w") as f:
json.dump(activities_list, f, indent=0)
Expand Down

0 comments on commit 280f339

Please sign in to comment.