Update update-data.yml #2
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
# Workflow to automate data updates from https://covid19.infn.it/ | |
# This workflow downloads the .tar.gzip data file, decompresses and processes it, commits the results to the repository, and creates a new release. | |
# For detailed information about workflows, see the GitHub documentation: https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions | |
# Workflow name | |
name: Update Data | |
# Define triggers for the workflow | |
on: | |
push: | |
branches: | |
- 'main' # Run the workflow on every push to the 'main' branch | |
# Uncomment the following to run the workflow on a schedule (currently set to every Wednesday at 10:59 PM UTC) | |
# schedule: | |
# - cron: '59 22 * * 3' | |
workflow_dispatch: # Allow manual triggering of the workflow from the GitHub Actions interface | |
# Workflows are structured as jobs, and each job includes sequential steps | |
jobs: | |
# Job to download, process, and update data | |
build: | |
# Specify the environment for the job | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository on the 'main' branch | |
- name: Checkout repository content | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Ensure all commits and tags are fetched to enable version history access | |
# Step 2: Set up Python environment and required dependencies | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' # Use Python version 3.10 | |
- name: Install Python packages | |
run: | | |
python -m pip install --upgrade pip # Upgrade pip | |
pip install requests # Required for HTTP requests in data download script | |
pip install matplotlib # Required by PyPlot in Julia | |
# Step 3: Run the Python script to download and extract data | |
- name: Execute download_extract.py | |
run: | | |
python src/download_extract.py | |
# Step 4: Set up Julia environment | |
- name: Set up Julia | |
uses: julia-actions/[email protected] | |
with: | |
version: "1.8" # Use Julia version 1.8 | |
# Step 5: Run Julia scripts for data processing | |
- name: Execute data_organization.jl and main.jl | |
run: | | |
julia src/data_organization.jl | |
julia src/main.jl | |
# Step 6: Commit and push updated data to the repository | |
- name: Commit files | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add -A | |
git commit -m "update data" -a | |
- name: Push changes | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main | |
# Step 7: Create a new release with updated data | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" # Capture the current date for release description | |
- name: Get Previous tag | |
id: previoustag | |
uses: WyriHaximus/github-action-get-previous-tag@v1 | |
with: | |
fallback: v1.0.0 # Fallback to 'v1.0.0' if no previous tags exist | |
- name: Get next major version | |
id: semvers | |
uses: WyriHaximus/github-action-next-semvers@v1 | |
with: | |
version: ${{ steps.previoustag.outputs.tag }} # Increment the previous tag to the next major version | |
- name: Create release | |
id: release | |
uses: ncipollo/release-action@v1 | |
with: | |
body: "Data updated as of ${{ steps.date.outputs.date }}" # Release description with date | |
tag: ${{ steps.semvers.outputs.v_major }} # New version tag | |
token: ${{ secrets.GITHUB_TOKEN }} # Authorization token |