Skip to content
Open
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
144 changes: 131 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,23 @@ inputs:
publish_path_outpout:
description: "Chemin de publication de l'IG."
required: false
default: ""
default: ""
ig_registry_fork_owner:
description: "Propriétaire du fork ig-registry pour les PRs (ex: ansforge)"
required: false
default: "ansforge"
enable_ig_registry_pr:
description: "Active la création automatique de PR vers FHIR/ig-registry"
required: false
default: "true"
ig_registry_authority:
description: "Authority pour fhir-ig-list.json (ex: ANS (FR))"
required: false
default: "ANS (FR)"
ig_registry_country:
description: "Country code pour fhir-ig-list.json (ex: fr)"
required: false
default: "fr"
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -284,33 +300,135 @@ runs:
path: IG-website-release

#Initialisation du repo
- name: Init publish_repo
if: ${{ inputs.publish_repo != '' }}
- name: Init publish_repo
if: ${{ inputs.publish_repo != '' }}
shell: bash
run: |
cd IG-website-release
git submodule update --init --recursive

#Synchronisation du fork ig-registry avec upstream FHIR/ig-registry
- name: Sync ig-registry fork with upstream
if: ${{ inputs.enable_ig_registry_pr == 'true' && inputs.ig_registry_fork_owner != '' }}
shell: bash
env:
FORK_OWNER: ${{ inputs.ig_registry_fork_owner }}
GH_TOKEN: ${{ inputs.publish_repo_token }}
run: |
cd IG-website-release/ig-registry
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Add upstream remote (FHIR/ig-registry)
git remote add upstream https://github.com/FHIR/ig-registry.git || true

# Fetch upstream and merge
git fetch upstream
git checkout main || git checkout master
git merge upstream/main --no-edit || git merge upstream/master --no-edit

# Push to personal fork to keep it synced
git push https://x-access-token:${GH_TOKEN}@github.com/${FORK_OWNER}/ig-registry.git HEAD:main

#Lancement de la release dans le repo
- name: 🏃‍♂️ Run Publisher to release
if: ${{ inputs.publish_repo != '' }}
shell: bash
run : java -jar publisher.jar -go-publish -authorise-non-conformant-tx-servers -source ${{ inputs.repo_ig}} -web ${{ inputs.publish_path_outpout }} -registry ./IG-website-release/ig-registry/fhir-ig-list.json -history ./IG-website-release/fhir-ig-history-template -templates ./IG-website-release/templates

if: ${{ inputs.publish_repo != '' }}
shell: bash
run : java -jar publisher.jar -go-publish -authorise-non-conformant-tx-servers -source ${{ inputs.repo_ig}} -web ${{ inputs.publish_path_outpout }} -registry ./IG-website-release/ig-registry/fhir-ig-list.json -history ./IG-website-release/fhir-ig-history-template -templates ./IG-website-release/templates

#Détection des changements dans ig-registry et création de branche
- name: Commit and push ig-registry changes
if: ${{ inputs.enable_ig_registry_pr == 'true' && inputs.ig_registry_fork_owner != '' }}
shell: bash
env:
FORK_OWNER: ${{ inputs.ig_registry_fork_owner }}
GH_TOKEN: ${{ inputs.publish_repo_token }}
IG_AUTHORITY: ${{ inputs.ig_registry_authority }}
IG_COUNTRY: ${{ inputs.ig_registry_country }}
REPO_IG: ${{ inputs.repo_ig }}
run: |
cd IG-website-release/ig-registry

# Check if there are changes in fhir-ig-list.json
if git diff --quiet fhir-ig-list.json; then
echo "No changes in ig-registry, skipping PR creation"
echo "CREATE_PR=false" >> $GITHUB_ENV
else
echo "Changes detected in ig-registry"

# Extract package ID from publication-request.json
PACKAGE_ID=$(jq -r '."package-id"' "../../${REPO_IG}/publication-request.json")
echo "Package ID: $PACKAGE_ID"

# Update authority and country in fhir-ig-list.json using sed
# This preserves the original formatting and only modifies the relevant fields
sed -i.bak -e '
/"npm-name"[[:space:]]*:[[:space:]]*"'"$PACKAGE_ID"'"/,/"editions"[[:space:]]*:/ {
s|\("authority"[[:space:]]*:[[:space:]]*\)"[^"]*"|\1"'"$IG_AUTHORITY"'"|
s|\("country"[[:space:]]*:[[:space:]]*\)"[^"]*"|\1"'"$IG_COUNTRY"'"|
}
' fhir-ig-list.json
rm -f fhir-ig-list.json.bak

echo "CREATE_PR=true" >> $GITHUB_ENV

# Create a new branch for the PR
BRANCH_NAME="ans-update-$(date +%Y%m%d-%H%M%S)"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV

git checkout -b "$BRANCH_NAME"
git add fhir-ig-list.json

# Commit with multi-line message
git commit -m "Update ANS FHIR Implementation Guides" -m "Automated update from ANS IG publication workflow." -m "This commit updates the FHIR IG registry with the latest ANS Implementation Guides."

# Push to personal fork
git push -u https://x-access-token:${GH_TOKEN}@github.com/${FORK_OWNER}/ig-registry.git "$BRANCH_NAME"
fi

#Création de la Pull Request vers FHIR/ig-registry
- name: Create Pull Request to FHIR/ig-registry
if: ${{ inputs.enable_ig_registry_pr == 'true' && env.CREATE_PR == 'true' }}
shell: bash
env:
GH_TOKEN: ${{ inputs.publish_repo_token }}
FORK_OWNER: ${{ inputs.ig_registry_fork_owner }}
PR_BRANCH: ${{ env.BRANCH_NAME }}
REPO_IG: ${{ inputs.repo_ig }}
run: |
# Extract package ID and version from publication-request.json
PACKAGE_ID=$(jq -r '."package-id"' "${REPO_IG}/publication-request.json")
VERSION=$(jq -r '.version' "${REPO_IG}/publication-request.json")

cd IG-website-release/ig-registry
gh pr create \
--repo FHIR/ig-registry \
--head "${FORK_OWNER}:${PR_BRANCH}" \
--title "ANS (french e-health agency) - Add new IG in the fhir-ig-list - ${PACKAGE_ID} - v${VERSION}" \
--body "Automated PR from ANS Publication Workflow. This PR updates the FHIR IG registry with the latest ANS (Agence du Numérique en Santé) Implementation Guide: **${PACKAGE_ID}** version **${VERSION}**. Please review and merge if the changes look correct."

#Commit de la release
- name: Commit change
if: ${{ inputs.publish_repo != '' }}
shell: bash
if: ${{ inputs.publish_repo != '' }}
shell: bash
env:
REPO_IG: ${{ inputs.repo_ig }}
run: |
PACKAGE_ID=$(jq -r '."package-id"' ${{ inputs.repo_ig}}/publication-request.json)
VERSION=$(jq -r '.version' ${{ inputs.repo_ig}}/publication-request.json)
# Extract package ID and version from publication-request.json
PACKAGE_ID=$(jq -r '."package-id"' "${REPO_IG}/publication-request.json")
VERSION=$(jq -r '.version' "${REPO_IG}/publication-request.json")

cd IG-website-release

# Reset ig-registry submodule to avoid including unreleased changes
# The ig-registry changes are already pushed to a separate branch and will be merged via PR
git submodule update --init ig-registry

git config user.name github-actions
git config user.email github-actions@esante.gouv.fr
git add -A
git add -A
git commit -m "Publication ${PACKAGE_ID} ${VERSION}" || echo "No changes to commit"

#Push de la release
- name: Push changes
if: ${{ inputs.publish_repo != '' }}
Expand Down