From 3e0967e9b9d68a8096a57010bf315d70f33b8093 Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:36:29 +0100 Subject: [PATCH 01/11] update action --- action.yml | 92 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 81 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index 3ffa8db..d60be7c 100644 --- a/action.yml +++ b/action.yml @@ -46,7 +46,15 @@ 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: nriss)" + required: false + default: "" + enable_ig_registry_pr: + description: "Active la création automatique de PR vers FHIR/ig-registry" + required: false + default: "false" runs: using: "composite" steps: @@ -284,30 +292,92 @@ 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 + 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:${{ inputs.github_page_token }}@github.com/${{ inputs.ig_registry_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 + 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" + 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 https://x-access-token:${{ inputs.github_page_token }}@github.com/${{ inputs.ig_registry_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.github_page_token }} + run: | + cd IG-website-release/ig-registry + gh pr create \ + --repo FHIR/ig-registry \ + --head ${{ inputs.ig_registry_fork_owner }}:${{ env.BRANCH_NAME }} \ + --title "Update ANS FHIR Implementation Guides" \ + --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 Guides. 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 run: | cd IG-website-release git config user.name github-actions git config user.email github-actions@esante.gouv.fr - git add -A - git commit -m updated + git add -A + git commit -m updated || echo "No changes to commit" #Push de la release - name: Push changes From 68e203dbdbd02e2630f07b2bd973bf9c2101f1b8 Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Wed, 17 Dec 2025 15:28:03 +0100 Subject: [PATCH 02/11] update --- action.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index d60be7c..fffa82f 100644 --- a/action.yml +++ b/action.yml @@ -303,6 +303,9 @@ runs: - 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.github_page_token }} run: | cd IG-website-release/ig-registry git config user.name "github-actions[bot]" @@ -317,7 +320,7 @@ runs: 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:${{ inputs.github_page_token }}@github.com/${{ inputs.ig_registry_fork_owner }}/ig-registry.git HEAD:main + 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 @@ -329,6 +332,9 @@ runs: - 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.github_page_token }} run: | cd IG-website-release/ig-registry @@ -344,14 +350,14 @@ runs: BRANCH_NAME="ans-update-$(date +%Y%m%d-%H%M%S)" echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV - git checkout -b $BRANCH_NAME + 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 https://x-access-token:${{ inputs.github_page_token }}@github.com/${{ inputs.ig_registry_fork_owner }}/ig-registry.git $BRANCH_NAME + git push 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 @@ -360,11 +366,13 @@ runs: shell: bash env: GH_TOKEN: ${{ inputs.github_page_token }} + FORK_OWNER: ${{ inputs.ig_registry_fork_owner }} + PR_BRANCH: ${{ env.BRANCH_NAME }} run: | cd IG-website-release/ig-registry gh pr create \ --repo FHIR/ig-registry \ - --head ${{ inputs.ig_registry_fork_owner }}:${{ env.BRANCH_NAME }} \ + --head "${FORK_OWNER}:${PR_BRANCH}" \ --title "Update ANS FHIR Implementation Guides" \ --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 Guides. Please review and merge if the changes look correct." From 3d80ea60a10b1f395cf1ad43c3dc967ddb2efbcd Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Wed, 17 Dec 2025 15:36:21 +0100 Subject: [PATCH 03/11] Update action.yml --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index fffa82f..4e0f821 100644 --- a/action.yml +++ b/action.yml @@ -48,9 +48,9 @@ inputs: required: false default: "" ig_registry_fork_owner: - description: "Propriétaire du fork ig-registry pour les PRs (ex: nriss)" + description: "Propriétaire du fork ig-registry pour les PRs (ex: ansforge)" required: false - default: "" + default: "nriss" enable_ig_registry_pr: description: "Active la création automatique de PR vers FHIR/ig-registry" required: false From 74a2f265e1aeb95b16fae7bb431b3005c7e0fb0b Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Wed, 17 Dec 2025 15:40:00 +0100 Subject: [PATCH 04/11] update --- action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 4e0f821..334c274 100644 --- a/action.yml +++ b/action.yml @@ -381,11 +381,15 @@ runs: if: ${{ inputs.publish_repo != '' }} shell: bash run: | + # Extract package ID and version from publication-request.json + PACKAGE_ID=$(jq -r '."package-id"' ${{ inputs.repo_ig}}/publication-request.json) + VERSION=$(jq -r '.version' ${{ inputs.repo_ig}}/publication-request.json) + cd IG-website-release git config user.name github-actions git config user.email github-actions@esante.gouv.fr git add -A - git commit -m updated || echo "No changes to commit" + git commit -m "Publication ${PACKAGE_ID} ${VERSION}" || echo "No changes to commit" #Push de la release - name: Push changes From ddea017e08929c627867026f6fc766309e68b279 Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Wed, 17 Dec 2025 16:09:10 +0100 Subject: [PATCH 05/11] Change default value of enable_ig_registry_pr to true --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 334c274..e7abc8a 100644 --- a/action.yml +++ b/action.yml @@ -54,7 +54,7 @@ inputs: enable_ig_registry_pr: description: "Active la création automatique de PR vers FHIR/ig-registry" required: false - default: "false" + default: "true" runs: using: "composite" steps: From f7d2325c28a3e038578b5d487f6be3b46f05052d Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Thu, 18 Dec 2025 12:03:31 +0100 Subject: [PATCH 06/11] Change default fork owner to 'ansforge' in action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e7abc8a..bb80d6a 100644 --- a/action.yml +++ b/action.yml @@ -50,7 +50,7 @@ inputs: ig_registry_fork_owner: description: "Propriétaire du fork ig-registry pour les PRs (ex: ansforge)" required: false - default: "nriss" + default: "ansforge" enable_ig_registry_pr: description: "Active la création automatique de PR vers FHIR/ig-registry" required: false From 0130ecd51ac3a5c6a8531fccb3f13392920a6881 Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Thu, 18 Dec 2025 14:25:59 +0100 Subject: [PATCH 07/11] udpate action --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index bb80d6a..7810398 100644 --- a/action.yml +++ b/action.yml @@ -305,7 +305,7 @@ runs: shell: bash env: FORK_OWNER: ${{ inputs.ig_registry_fork_owner }} - GH_TOKEN: ${{ inputs.github_page_token }} + GH_TOKEN: ${{ inputs.publish_repo_token }} run: | cd IG-website-release/ig-registry git config user.name "github-actions[bot]" @@ -334,7 +334,7 @@ runs: shell: bash env: FORK_OWNER: ${{ inputs.ig_registry_fork_owner }} - GH_TOKEN: ${{ inputs.github_page_token }} + GH_TOKEN: ${{ inputs.publish_repo_token }} run: | cd IG-website-release/ig-registry @@ -365,7 +365,7 @@ runs: if: ${{ inputs.enable_ig_registry_pr == 'true' && env.CREATE_PR == 'true' }} shell: bash env: - GH_TOKEN: ${{ inputs.github_page_token }} + GH_TOKEN: ${{ inputs.publish_repo_token }} FORK_OWNER: ${{ inputs.ig_registry_fork_owner }} PR_BRANCH: ${{ env.BRANCH_NAME }} run: | From c5e262b57be0bc4d760ca5c15af83aee91d6ffe5 Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Thu, 18 Dec 2025 14:54:26 +0100 Subject: [PATCH 08/11] update action --- action.yml | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 7810398..d4dd6ba 100644 --- a/action.yml +++ b/action.yml @@ -55,6 +55,14 @@ inputs: 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: @@ -335,6 +343,8 @@ runs: 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 }} run: | cd IG-website-release/ig-registry @@ -344,6 +354,22 @@ runs: 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"' ../../${{ inputs.repo_ig}}/publication-request.json) + echo "Package ID: $PACKAGE_ID" + + # Update authority and country in fhir-ig-list.json using jq + jq --arg pkg "$PACKAGE_ID" --arg auth "$IG_AUTHORITY" --arg country "$IG_COUNTRY" ' + .guides = (.guides | map( + if (.["npm-name"] == $pkg) then + .authority = $auth | .country = $country + else + . + end + )) + ' fhir-ig-list.json > fhir-ig-list.json.tmp && mv fhir-ig-list.json.tmp fhir-ig-list.json + echo "CREATE_PR=true" >> $GITHUB_ENV # Create a new branch for the PR @@ -369,12 +395,16 @@ runs: FORK_OWNER: ${{ inputs.ig_registry_fork_owner }} PR_BRANCH: ${{ env.BRANCH_NAME }} run: | + # Extract package ID and version from publication-request.json + PACKAGE_ID=$(jq -r '."package-id"' ${{ inputs.repo_ig}}/publication-request.json) + VERSION=$(jq -r '.version' ${{ inputs.repo_ig}}/publication-request.json) + cd IG-website-release/ig-registry gh pr create \ --repo FHIR/ig-registry \ --head "${FORK_OWNER}:${PR_BRANCH}" \ - --title "Update ANS FHIR Implementation Guides" \ - --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 Guides. Please review and merge if the changes look correct." + --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 From 4fe75e0de8f672871b2967b65eba31e20e9edbbf Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Thu, 18 Dec 2025 15:03:37 +0100 Subject: [PATCH 09/11] resolve issues --- action.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index d4dd6ba..fc02e2e 100644 --- a/action.yml +++ b/action.yml @@ -345,6 +345,7 @@ runs: 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 @@ -356,7 +357,7 @@ runs: echo "Changes detected in ig-registry" # Extract package ID from publication-request.json - PACKAGE_ID=$(jq -r '."package-id"' ../../${{ inputs.repo_ig}}/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 jq @@ -394,10 +395,11 @@ runs: 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"' ${{ inputs.repo_ig}}/publication-request.json) - VERSION=$(jq -r '.version' ${{ inputs.repo_ig}}/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 \ @@ -410,10 +412,12 @@ runs: - name: Commit change if: ${{ inputs.publish_repo != '' }} shell: bash + env: + REPO_IG: ${{ inputs.repo_ig }} run: | # Extract package ID and version from publication-request.json - PACKAGE_ID=$(jq -r '."package-id"' ${{ inputs.repo_ig}}/publication-request.json) - VERSION=$(jq -r '.version' ${{ inputs.repo_ig}}/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 git config user.name github-actions From 51cce3d2d682a0fc791b9f4c7450493f8da57c2f Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Fri, 19 Dec 2025 10:22:50 +0100 Subject: [PATCH 10/11] update --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index fc02e2e..1d342eb 100644 --- a/action.yml +++ b/action.yml @@ -384,7 +384,7 @@ runs: 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 https://x-access-token:${GH_TOKEN}@github.com/${FORK_OWNER}/ig-registry.git "$BRANCH_NAME" + 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 From 49dc65887a13abd26bd06c284f58589f761008d4 Mon Sep 17 00:00:00 2001 From: Nicolas Riss <48218773+nriss@users.noreply.github.com> Date: Fri, 19 Dec 2025 11:11:38 +0100 Subject: [PATCH 11/11] update --- action.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/action.yml b/action.yml index 1d342eb..47799bb 100644 --- a/action.yml +++ b/action.yml @@ -360,16 +360,15 @@ runs: 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 jq - jq --arg pkg "$PACKAGE_ID" --arg auth "$IG_AUTHORITY" --arg country "$IG_COUNTRY" ' - .guides = (.guides | map( - if (.["npm-name"] == $pkg) then - .authority = $auth | .country = $country - else - . - end - )) - ' fhir-ig-list.json > fhir-ig-list.json.tmp && mv fhir-ig-list.json.tmp fhir-ig-list.json + # 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 @@ -420,6 +419,11 @@ runs: 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