Skip to content

Combine CSV Files

Combine CSV Files #79

Workflow file for this run

name: Combine CSV Files
on:
workflow_dispatch:
schedule:
- cron: "17 3 * * 2-6" # Runs at 10:17 PM ET (3:17 am UTC) on weekdays
jobs:
combine_csv:
runs-on: ubuntu-latest
steps:
- name: Set branch name
id: branch_name
run: echo ::set-output name=branch_name::daily-branch-$(TZ='America/Toronto' date +'%Y-%m-%d')
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ steps.branch_name.outputs.branch_name }}
- name: Set Up Git
run: git config --global user.email "[email protected]" && git config --global user.name "GitHub Actions"
- name: Merge data CSV Files into one and remove the rest
run: |
cat *.csv > combined.csv
find . -maxdepth 1 -type f -name "*.csv" -not -name "combined.csv" -exec rm -f {} \;
- name: Rename Combined CSV and move to collected_data/
run: |
mv combined.csv "collected_data/combined_${{ steps.branch_name.outputs.branch_name }}.csv"
- name: Commit and Push Changes
run: |
git add .
git commit -m "Merge CSV Files into one and remove the rest"
git push
- name: Squash and merge
run: |
git fetch origin main
git checkout main
git merge --allow-unrelated-histories --squash ${{ steps.branch_name.outputs.branch_name }}
git commit -m "Squashed daily commits for ${{ steps.branch_name.outputs.branch_name }}"
git push origin main
- name: Delete branch
run: |
git push --delete origin ${{ steps.branch_name.outputs.branch_name }}
git branch -D ${{ steps.branch_name.outputs.branch_name }}