Skip to content

Commit

Permalink
Update Worklfows
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWuensche committed Apr 22, 2024
1 parent 4b063f8 commit 9df5243
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 167 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/Build_and_deploy_website.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
name: Build and deploy OpenData-Website

name: Manually build and deploy OpenData-Website
on:
workflow_dispatch:
workflow_run:
workflows: ["Create release on tag push"]
types:
- completed

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
name: Bulid and deploy OpenData Website
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
runs-on: ubuntu-latest
steps:
- name: Bulid and deploy OpenData Website
uses: robert-koch-institut/OpenData-Website@main
with:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Bulid and deploy OpenData Website
uses: robert-koch-institut/OpenData-Website@main
with:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 0 additions & 30 deletions .github/workflows/Create_release_on_tag_push.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/Create_release_with_latest_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Manually create relese with latest tag
on:
workflow_dispatch:

permissions:
contents: write

jobs:
create_release:
name: Create reslese
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get latest tag and set env
run: |
echo "LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: robert-koch-institut/OpenData-Workflows/Create_release_on_tag_push@main
with:
REF_NAME: ${{ env.LATEST_TAG }}
40 changes: 40 additions & 0 deletions .github/workflows/OpenData_Workfow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: OpenData Workfow for FAIR Data
on:
push:
tags:
- '[0-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]'
#workflow_dispatch:

jobs:
build:
uses: robert-koch-institut/OpenData-Workflows/.github/workflows/OpenData_Workflows.yml@main
with:
# Push to OpenCoDE
OPENCODE_ACTIVE: true
OPENCODE_GROUPID: 2781
OPENCODE_ACCESS_USER: RKIOpenData
OPENCODE_ZENODOJSON_PATH: Metadaten/zenodo.json

# Push to GovData Repositoy
GOVDATA_ACTIVE: true
GOVDATA_DESTINATION_REPO: robert-koch-institut/Metadaten_fuer_GovData

# Push to NFDI4Health
NFDI4HEALTH_ACTIVE: true

#Build Open Data Website
WEBSITE_ACTIVE: true

secrets:
# Token from GovData Repository
GOVDATA_GITHUB_TOKEN: ${{secrets.GOVDATA_TOKEN}}

# Token from OpenCoDE Account
OPENCODE_TOKEN: ${{secrets.OPENCODE_TOKEN}}

# NFDI4Health Credentials
NFDI4HEALTH_CLIENT_ID: CSH_RKI_CLIENT
NFDI4HEALTH_CLIENT_SECRET: ${{secrets.NFDI4HEALTH_SECRET}}

# Github Token
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
49 changes: 11 additions & 38 deletions .github/workflows/Send_metadata_to_Govdata.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,44 +1,17 @@
name: Send metadata to Govdata
name: Manually send metadata to GovData
on:
workflow_dispatch:
push:
paths:
- 'Metadaten/**.ttl'

permissions:
contents: write

jobs:
Push_Govdata_ttl:
name: Push metadata to Govdata-Repository
push_govdata:
name: Push ttl to GovData repository
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Rename ttl with reponame
run: cp Metadaten/govdata.ttl Metadaten/${{ github.event.repository.name }}.ttl

- name: Push dataset ttl to Govdata repository
id: pushStep1
continue-on-error: true
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.GOVDATA_TOKEN }}
- name: run GovData Action
uses: robert-koch-institut/OpenData-Workflows/Send_metadata_to_Govdata@main
with:
source_file: 'Metadaten/${{ github.event.repository.name }}.ttl'
destination_repo: 'robert-koch-institut/Metadaten_fuer_GovData'
destination_folder: 'Datensaetze'
commit_message: 'adding ${{ github.event.repository.name }}.ttl'
user_email: '[email protected]'
user_name: 'RKIOpenData'

- name: Retry push dataset ttl to Govdata repository
id: pushStep2
if: steps.pushStep1.outcome == 'failure'
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.GOVDATA_TOKEN }}
with:
source_file: 'Metadaten/${{ github.event.repository.name }}.ttl'
destination_repo: 'robert-koch-institut/Metadaten_fuer_GovData'
destination_folder: 'Datensaetze'
commit_message: 'adding ${{ github.event.repository.name }}.ttl'
user_email: '[email protected]'
user_name: 'RKIOpenData'
govdata_github_token: ${{secrets.GOVDATA_TOKEN}}
destination_repo: robert-koch-institut/Metadaten_fuer_GovData
18 changes: 18 additions & 0 deletions .github/workflows/Send_metadata_to_nfdi4health.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Manually send metadata to NFDI4Health
on:
workflow_dispatch:

jobs:
sync_opencode:
name: Send metadata to NFDI4Health
runs-on: ubuntu-latest
steps:
- name: Sync Github Open Data repository
uses: robert-koch-institut/OpenData-Workflows/Send_metadata_to_NFDI4Health@main
with:
nfdi4health_client_id: CSH_RKI_CLIENT
nfdi4health_client_secret: ${{secrets.NFDI4HEALTH_SECRET}}
nfdi4health_metadata_path: Metadaten/nfdi4health.json
nfdi4health_authorization_endpoint: "https://sso.studyhub.nfdi4health.de/realms/nfdi4health/protocol/openid-connect/token"
github_token: ${{secrets.GITHUB_TOKEN}}
nfdi4health_base_url: "https://csh.nfdi4health.de/api/"
95 changes: 11 additions & 84 deletions .github/workflows/Sync_OpenData_repo_to_OpenCoDE.yml
Original file line number Diff line number Diff line change
@@ -1,92 +1,19 @@
name: Sync Github Open Data repository and its metadata to OpenCoDE.de
name: Manually sync Github Open Data repository and its metadata to OpenCoDE.de

on:
workflow_dispatch:
workflow_run:
workflows: ["Create release on tag push"]
types:
- completed

env:
# OpenCoDE Metadata
GROUP_ID: 2781
ACCESS_USER: RKIOpenData

# The repository name must not start or end with a special character and must not contain consecutive special characters
REPO_PATH: ${{ github.event.repository.name }}
ZENODOJSON_PATH: Metadaten/zenodo.json

jobs:
sync_metadata_to_opencode:
name: Sync Open Data metadata to OpenCoDE
sync_opencode:
name: Sync Github Open Data repository and its metadata to OpenCoDE.de
runs-on: ubuntu-latest
outputs:
GROUP_PATH: ${{ steps.group_path.outputs.GROUP_PATH }}
steps:

# Get OpenCoDE group path from the OpenCoDE API
- name: Get OpencoDE group path
id: group_path
run: |
GROUP_INFO=$(curl \
--request GET "https://gitlab.opencode.de/api/v4/groups/$GROUP_ID" \
--header "PRIVATE-TOKEN: ${{ secrets.OPENCODE_TOKEN }}")
# Add metadata to enviroment
echo "GROUP_PATH="$(echo $GROUP_INFO | jq -r '.path')"" >> $GITHUB_OUTPUT
# Get metadata on name, description and keywords from the zenodo.json
- name: Get zenodo.json metadata from Github Open Data repository
run: |
ZENODOJSON_URL=$(curl \
--request GET https://api.github.com/repos/${{ github.repository }}/contents/${{ env.ZENODOJSON_PATH }} \
--header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--header "Accept: application/vnd.github.mercy-preview+json" \
| jq -r '.download_url')
# Add Zenodo metadata to enviroment
echo "REPO_NAME="$(curl $ZENODOJSON_URL | jq -r '.title')"" >> $GITHUB_ENV
echo "DESCRIPTION="$(curl $ZENODOJSON_URL | jq -r '.description'| head -c 2000)"" >> $GITHUB_ENV
echo "TOPICS="$(curl $ZENODOJSON_URL| jq -r '.keywords | join(",")')"" >> $GITHUB_ENV

- name: Create OpenCoDE repository and update repository metadata
run: |
# Create OpenCoDE repository
curl \
--request POST "https://gitlab.opencode.de/api/v4/projects" \
--header "PRIVATE-TOKEN: ${{ secrets.OPENCODE_TOKEN }}" \
--data-urlencode "path=${{ env.REPO_PATH }}" \
--data-urlencode "namespace_id=${{ env.GROUP_ID }}"
# Update OpenCoDE repository metadata
response=$(curl \
--request PUT "https://gitlab.opencode.de/api/v4/projects/${{ steps.group_path.outputs.GROUP_PATH }}%2F${{ env.REPO_PATH }}" \
--header "PRIVATE-TOKEN: ${{ secrets.OPENCODE_TOKEN }}" \
--data "name=${{ env.REPO_NAME }}" \
--data "description=${{ env.DESCRIPTION }}" \
--data "topics='${{ env.TOPICS }}'" \
--data "visibility=public")
sync_data_to_opencode:
name: Sync Github Open Data repository data to OpenCoDE
needs: sync_metadata_to_opencode
runs-on: ubuntu-latest
steps:

# Clone Github Open Data repository into the action enviroment
- name: Checkout Github repository
uses: actions/checkout@v3
- name: Sync Github Open Data repository
uses: robert-koch-institut/OpenData-Workflows/Sync_OpenData_repo_to_OpenCoDE@main
with:
persist-credentials: false
lfs: 'true'
ref: 'main'
fetch-depth: '0'

# Force push latest Github Open Data repository status to OpenCoDE
- name: Force push latest status to OpenCoDE
run: |
git remote add opencode https://${{ env.ACCESS_USER }}:${{ secrets.OPENCODE_TOKEN }}@gitlab.opencode.de/${{ needs.sync_metadata_to_opencode.outputs.GROUP_PATH }}/${{ env.REPO_PATH }}.git
git push opencode -f
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENCODE_TOKEN: ${{ secrets.OPENCODE_TOKEN }}
GROUP_ID: 2781
ACCESS_USER: RKIOpenData
# REPO_PATH: The repository name must not start or end with a special character and must not contain consecutive special characters
ZENODOJSON_PATH: Metadaten/zenodo.json

0 comments on commit 9df5243

Please sign in to comment.