I14Y Harvester FSVO data repository PROD #15
This file contains hidden or 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
name: I14Y Harvester FSVO data repository PROD | |
on: | |
# uncomment the two lines to start automatic harvesting | |
schedule: | |
- cron: '0 3 * * 1' # Automatisches Ausführen jeden Montag um 03:00 | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
harvest-data: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download previous data | |
uses: dawidd6/action-download-artifact@v4 | |
continue-on-error: true | |
with: | |
name: IDS-I14Y-json | |
workflow: harvester_abn.yml | |
workflow_conclusion: success | |
if_no_artifact_found: warn | |
path: unisante/data | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Get access token | |
id: get-token | |
env: | |
CLIENT_ID: ${{ secrets.CLIENT_ID_PROD}} # client PROD | |
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET_PROD}} # secret PROD | |
run: | | |
python - <<EOF | |
import requests | |
import os | |
import json | |
def get_token_without_refresh(client_id,client_secret): | |
data = { | |
'grant_type': 'client_credentials', | |
} | |
response = requests.post( | |
"https://identity.bit.admin.ch/realms/bfs-sis-p/protocol/openid-connect/token", | |
data=data, | |
verify=False, | |
auth=(client_id,client_secret) | |
) | |
if response.status_code >= 400: | |
print(response.status_code) | |
print(response.text) | |
raise Exception("Failed to get token") | |
return response.json() | |
client_id = os.environ['CLIENT_ID'] | |
client_secret = os.environ['CLIENT_SECRET'] | |
result = get_token_without_refresh(client_id,client_secret) | |
print(f"::set-output name=access_token::{result['access_token']}") | |
EOF | |
- name: Run harvester script | |
env: | |
ACCESS_TOKEN: ${{ steps.get-token.outputs.access_token }} | |
run: python src/harvester.py | |
- name: Upload log | |
uses: actions/upload-artifact@v4 | |
with: | |
name: harvest-log | |
path: harvest_log.txt |