Files
endoflife-date-release-data/.github/workflows/update.yml
Marc Wrobel 86860715ab Rewrite update.py to Python (#263)
Reasons were:

- one language make it easier for maintenance,
- workflow simplification,
- not stopping when a script fails anymore (it's better to have a partial update than nothing),
- use `GITHUB_OUTPUT` instead of the deprecated `set-output` command,
- display a workflow summary with statistics about scripts and information about updated products.

The commit message is not as good as it used to be, but it makes the diff process agnostic from the file format (will be needed soon when it will change), and it handles versions updates / removal, which was not supported by the previous script.
2023-12-30 00:07:22 +01:00

83 lines
2.6 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
uses: actions/cache@v3
with:
path: ~/.cache
# The cache is reset on the first build of every week this way.
# Change the -1 part if you need to force reset the cache
key: "${{ steps.current-time.outputs.formattedTime }}-2"
- uses: actions/checkout@v4
name: Clone self repository
with:
ref: ${{ github.head_ref }}
- uses: actions/checkout@v4
id: clone_same_branch
name: Clone website (Same Branch)
continue-on-error: true
with:
repository: endoflife-date/endoflife.date
path: website
submodules: false
ref: ${{github.ref_name}}
- uses: actions/checkout@v4
name: Clone website (Main)
if: steps.clone_same_branch.outcome != 'success'
with:
repository: endoflife-date/endoflife.date
path: website
submodules: false
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- run: pip install -r requirements.txt
- name: Update data
id: update_data
env:
PYPPETEER_HOME: /home/runner/.cache/pyppeteer # Add chromium downloaded by pyppeteer to the cache.
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: Set job status
if: steps.update_data.outcome != 'success'
run: exit 1