Allow stale responses in case of error in order to reduce the number of temporary errors. Note that the cache will be reset on the first build of every week in any cases, see .github/workflows/update.yml.
83 lines
2.8 KiB
YAML
83 lines
2.8 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:
|
|
- name: Get current week
|
|
uses: josStorer/get-current-time@v2
|
|
id: current-time
|
|
with:
|
|
format: YYYY-ww # 2022-01 to 2022-52 for eg
|
|
|
|
- name: Cache fetched repositories and HTTP requests
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache
|
|
# The cache is reset on the first build of every week this way. If you wish to reset the cache manually,
|
|
# you can do it on https://github.com/endoflife-date/release-data/actions/caches or by updating
|
|
# the last part of the key below.
|
|
key: "${{ steps.current-time.outputs.formattedTime }}-2"
|
|
|
|
- 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
|
|
|
|
- name: Commit changes
|
|
uses: stefanzweifel/git-auto-commit-action@v5
|
|
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>'
|
|
|
|
# we still want to easily know if something went wrong
|
|
- name: Restore update.py failure
|
|
if: steps.update_data.outcome != 'success'
|
|
run: exit 1
|