Get FIT File #4385
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: Get FIT File | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */2 * * *' | |
push: | |
branches: | |
- main | |
env: | |
GITHUB_NAME: shaonianche | |
GITHUB_EMAIL: [email protected] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Rclone action | |
uses: AnimMouse/setup-rclone@v1 | |
with: | |
rclone_config: ${{ secrets.RCLONE_CONFIG }} | |
- run: | | |
rclone sync "google drive:/HealthFit" ./FIT_OUT --update | |
- name: Rename file | |
run: | | |
cd ./FIT_OUT | |
for file in *.fit; do | |
new_name=$(echo "$file" | sed -E 's/^([0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}).*\.fit$/\1.fit/') | |
mv "$file" "$new_name" | |
done | |
cd .. | |
- name: Push fit file | |
run: | | |
git config --local user.email '${{ env.GITHUB_EMAIL }}' | |
git config --local user.name '${{ env.GITHUB_NAME }}' | |
git add . | |
git commit -a -m 'update fit file' || echo 'nothing to commit' | |
git push || echo 'nothing to push' |