Files
endoflife-date-release-data/.github/workflows/update.yml
Marc Wrobel c78d1fe2b5 Refactor scripts arguments handling (#456)
- remove the use of environment variables to get directory paths,
- make use of arguments / argparse instead of environment variables in `update.py` and `report.py`,
- automatically guess the data directory in `latest.py` based on the script's location,
- propagate log level to auto scripts,
- move `list_configs_from_argv` from `endoflife` module to `releasedata` module,
- use `list_products` in `latest.py` to load the product's frontmatters.
2025-06-28 19:05:07 +02:00

86 lines
3.0 KiB
YAML

name: Update Data
on:
workflow_dispatch:
push:
schedule:
# See https://crontab.guru/#17_6,18_*_*_*
- cron: '17 0,6,12,18 * * *'
# Cancel previous runs for a given branch if they are still running when a new one starts.
# This is useful to avoid errors as the same branch would be changed multiple times.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
update:
name: Update data
runs-on: ubuntu-latest
steps:
# Note that the cache will be destroyed every week by .github/workflows/clear-cache.yml.
# See https://github.com/actions/cache/tree/main/save#always-save-cache.
- name: Restore repositories and HTTP requests cache
id: cache-restore
uses: actions/cache/restore@v4
with:
key: 'update-cache'
path: ~/.cache
- name: Clone self repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Clone website repository
uses: actions/checkout@v4
with:
repository: endoflife-date/endoflife.date
path: website
submodules: false
fetch-depth: 0 # fetch all history for all branches and tags, needed for next step
# This is useful for testing changes that require updates on both release-data and website repositories.
# This step must never fail because in most case the branch will not exist on the website repository.
- name: Checkout the same branch on website
run: |
cd website
git checkout --progress --force -B ${{ github.ref_name }} refs/remotes/origin/${{ github.ref_name }} || true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Update release data
id: update_data
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true # commit even if the data was not fully updated
run: python update.py -p 'website/products'
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v6
if: steps.update_data.outputs.commit_message != ''
with:
commit_message: ${{ steps.update_data.outputs.commit_message }}
commit_author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
# See https://github.com/actions/cache/tree/main/save#always-save-cache.
- name: Save repositories and HTTP requests cache
id: cache-save
uses: actions/cache/save@v4
if: always() && steps.cache-restore.outputs.cache-hit != 'true'
with:
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
path: ~/.cache
# we still want to easily know if something went wrong
- name: Restore update.py failure
if: steps.update_data.outcome != 'success'
run: exit 1