Skip to content

Commit

Permalink
factorize
Browse files Browse the repository at this point in the history
  • Loading branch information
abulte committed Nov 13, 2024
1 parent e629f10 commit 7bb772e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 38 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/update-universes-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Update universe (base)

on:
workflow_call:
inputs:
env-name:
description: Name of the environment (demo or prod)
required: true
type: string
env-config-file:
description: Name of the universe configuration file
required: true
type: string
datagouv-url:
description: URL of the data.gouv.fr instance
required: true
type: string
api-key-secret:
description: Secret containing the API key
required: true
type: string

jobs:
update-universe:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Update universe
env:
DATAGOUV_URL: ${{ inputs.datagouv-url }}
DATAGOUV_API_KEY: ${{ secrets[inputs.api-key-secret] }}
run: |
python -u feed-universe.py ${{ inputs.env-config-file }} --dry-run 2>&1 | tee logs/run_log_${{ inputs.env-name }}.txt
- name: Commit Run Logs
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add logs/run_log_${{ inputs.env-name }}.txt
git commit -m "Update daily run log for ${{ inputs.env-name }}"
- name: Push changes
run: |
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52 changes: 14 additions & 38 deletions .github/workflows/update-universes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,29 @@ name: Update universes

on:
schedule:
- cron: '27 5 * * *'
- cron: '27 7 * * *'
# FIXME: remove
push:
branches:
- feat/ci

jobs:

run-update:
update-universes:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Update demo universe
env:
DATAGOUV_URL: https://demo.data.gouv.fr
DATAGOUV_API_KEY: ${{ secrets.DATAGOUV_API_KEY_DEMO }}
run: |
python -u feed-universe.py universe-demo.yaml --dry-run 2>&1 | tee logs/run_log_demo.txt
uses: ./.github/workflows/update-universes-base.yml
with:
env-name: demo
env-config-file: universe-demo.yaml
datagouv-url: https://demo.data.gouv.fr
api-key-secret: DATAGOUV_API_KEY_DEMO

- name: Update prod universe
env:
DATAGOUV_URL: https://www.data.gouv.fr
DATAGOUV_API_KEY: ${{ secrets.DATAGOUV_API_KEY_PROD }}
run: |
python -u feed-universe.py universe-prod.yaml --dry-run 2>&1 | tee logs/run_log_prod.txt
- name: Commit Run Logs
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add logs/
git commit -m "Update daily run logs"
- name: Push changes
run: |
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ./.github/workflows/update-universes-base.yml
with:
env-name: prod
env-config-file: universe-prod.yaml
datagouv-url: https://www.data.gouv.fr
api-key-secret: DATAGOUV_API_KEY_PROD

0 comments on commit 7bb772e

Please sign in to comment.