Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 0 additions & 103 deletions .github/workflows/generate-participants-nightly.yml

This file was deleted.

126 changes: 94 additions & 32 deletions .github/workflows/generate-participants.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
# Unified workflow that handles participant generation for all trigger types:
# 1. Scheduled nightly builds (processes all environments)
# 2. Manual workflow dispatch (flexible environment selection)
# 3. Repository webhook events (single environment based on source repo)
#
# This workflow consolidates the previous separate workflows:
# - generate-participants.yml (manual + webhook triggers)
# - generate-participants-nightly.yml (scheduled + manual triggers)

name: Generate Participants

permissions:
contents: write

on:
# Allows manual triggering
# Scheduled nightly at 2 AM UTC
schedule:
- cron: '0 2 * * *'

# Manual triggering with flexible environment options
workflow_dispatch:
inputs:
environment:
description: 'Environment to generate (PROD, UAT, DEV)'
environments:
description: 'Environments to generate (single: PROD/UAT/DEV, multiple: PROD,UAT,DEV, or "all")'
required: true
default: 'PROD'
type: choice
options:
- PROD
- UAT
- DEV
default: 'all'
type: string

# Webhook trigger from participant repositories
repository_dispatch:
Expand All @@ -38,6 +47,11 @@ jobs:
run: |
pip install pandas urllib3 requests cryptography

- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

- name: Validate webhook source
if: github.event_name == 'repository_dispatch'
id: validate
Expand Down Expand Up @@ -77,42 +91,90 @@ jobs:
echo "Webhook source validated: $SOURCE_REPO"
echo "source_repo=$SOURCE_REPO" >> $GITHUB_OUTPUT

- name: Determine environment
id: env
- name: Determine environments to process
id: environments
run: |
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
# Extract environment from repository name (part after last dash)
SOURCE_REPO="${{ steps.validate.outputs.source_repo }}"
ENV_SUFFIX=$(echo "$SOURCE_REPO" | sed 's/.*-//')
ENV=$(echo "$ENV_SUFFIX" | tr '[:lower:]' '[:upper:]')
echo "envs=$ENV" >> $GITHUB_OUTPUT
echo "Using environment from webhook: $ENV"
elif [ "${{ github.event_name }}" = "schedule" ]; then
# Nightly build processes all environments
echo "envs=PROD,UAT,DEV" >> $GITHUB_OUTPUT
echo "Using all environments for scheduled run"
else
# Use manual input
ENV="${{ github.event.inputs.environment }}"
# Manual workflow_dispatch
INPUT="${{ github.event.inputs.environments }}"
if [ -z "$INPUT" ] || [ "$INPUT" = "all" ]; then
echo "envs=PROD,UAT,DEV" >> $GITHUB_OUTPUT
echo "Using all environments for manual run"
else
echo "envs=$INPUT" >> $GITHUB_OUTPUT
echo "Using specified environments: $INPUT"
fi
fi
echo "environment=$ENV" >> $GITHUB_OUTPUT
echo "Using environment: $ENV"

- name: Generate organization files
- name: Generate participants
run: |
python3 input/scripts/generate_organizations.py --env ${{ steps.env.outputs.environment }} --source github-api
ENVIRONMENTS="${{ steps.environments.outputs.envs }}"
IFS=',' read -ra ENV_ARRAY <<< "$ENVIRONMENTS"

- name: Check for changes
id: changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
OVERALL_CHANGES=false
COMMIT_COUNT=0

for ENV in "${ENV_ARRAY[@]}"; do
ENV=$(echo "$ENV" | tr '[:lower:]' '[:upper:]' | xargs) # Trim whitespace and uppercase
echo "Processing environment: $ENV"

# Generate for this environment
python3 input/scripts/generate_organizations.py --env "$ENV" --source github-api

# Check if there are any changes for this environment
if [ -n "$(git status --porcelain)" ]; then
echo "Changes detected for $ENV environment"

# Stage the changes
git add input/fsh/instances/ input/fsh/codesystems/ input/fsh/valuesets/

# Check if there are staged changes (substantive changes, not just whitespace)
if [ -n "$(git diff --cached --name-only)" ]; then
# Determine commit message based on trigger type
if [ "${{ github.event_name }}" = "repository_dispatch" ]; then
COMMIT_MSG="Auto-update $ENV participants from repository changes"
elif [ "${{ github.event_name }}" = "schedule" ]; then
COMMIT_MSG="Auto-update $ENV participants from nightly generation ($(date -u +%Y-%m-%d))"
else
COMMIT_MSG="Auto-update $ENV participants from manual generation"
fi

# Commit the changes for this environment
git commit -m "$COMMIT_MSG"
OVERALL_CHANGES=true
COMMIT_COUNT=$((COMMIT_COUNT + 1))
echo "Committed changes for $ENV environment"
else
echo "No substantive changes for $ENV environment after staging"
git reset --hard HEAD # Reset any unstaged changes
fi
else
echo "No changes detected for $ENV environment"
fi
done

if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
echo "Changes detected"
# Push all commits if any changes were made
if [ "$OVERALL_CHANGES" = "true" ]; then
git push
echo "Pushed $COMMIT_COUNT environment update(s)"
else
echo "changes=false" >> $GITHUB_OUTPUT
echo "No changes detected"
echo "No changes to push"
fi

- name: Commit and push changes
if: steps.changes.outputs.changes == 'true'
- name: Summary
run: |
git add input/fsh/instances/ input/fsh/codesystems/ input/fsh/valuesets/
git commit -m "Auto-update ${{ steps.env.outputs.environment }} participants from repository changes"
git push
echo "Participant generation completed"
echo "Trigger: ${{ github.event_name }}"
echo "Processed environments: ${{ steps.environments.outputs.envs }}"
git log --oneline -5
30 changes: 30 additions & 0 deletions input/fsh/codesystems/Participants-DEV.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,36 @@ Description: "CodeSystem for GDHCN Trust Network Participants for Development en
* ^experimental = true
* ^caseSensitive = false
* ^url = "http://smart.who.int/trust/CodeSystems/Participants-DEV"
* #AND "DEV Participant AND"
* #ARG "DEV Participant ARG"
* #ARM "DEV Participant ARM"
* #BHS "DEV Participant BHS"
* #BLZ "DEV Participant BLZ"
* #BRA "DEV Participant BRA"
* #BRB "DEV Participant BRB"
* #CHL "DEV Participant CHL"
* #COL "DEV Participant COL"
* #CRI "DEV Participant CRI"
* #CYP "DEV Participant CYP"
* #DOM "DEV Participant DOM"
* #ECU "DEV Participant ECU"
* #EST "DEV Participant EST"
* #GTM "DEV Participant GTM"
* #HND "DEV Participant HND"
* #IDN "DEV Participant IDN"
* #LVA "DEV Participant LVA"
* #OMN "DEV Participant OMN"
* #PAN "DEV Participant PAN"
* #PER "DEV Participant PER"
* #PRY "DEV Participant PRY"
* #SGP "DEV Participant SGP"
* #SLV "DEV Participant SLV"
* #SMR "DEV Participant SMR"
* #SUR "DEV Participant SUR"
* #SVN "DEV Participant SVN"
* #TGO "DEV Participant TGO"
* #URY "DEV Participant URY"
* #USA "DEV Participant USA"
* #WHO "DEV Participant WHO"
* #XCL "DEV Participant XCL"
* #XML "DEV Participant XML"
Expand Down
Loading