From 744681f9e0e9a4c7e7c441e870d2c7f24f949b74 Mon Sep 17 00:00:00 2001
From: Avnish Pratap Singh <as74@sanger.ac.uk>
Date: Mon, 8 Jul 2024 19:00:42 +0100
Subject: [PATCH] Automatic Confluence Update

---
 .gitlab-ci.yml                 | 29 +++++++++++++++++++++++++++++
 Changes                        |  3 +++
 docs/api_usage.md              | 17 +++++++++++++++++
 docs/includes/repo-metadata.md |  1 +
 docs/instruments.md            | 17 +++++++++++++++++
 docs/run_states.md             | 17 +++++++++++++++++
 docs/user_management.md        | 17 +++++++++++++++++
 7 files changed, 101 insertions(+)
 create mode 100644 .gitlab-ci.yml
 create mode 100644 docs/includes/repo-metadata.md

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 00000000..76ae9d2a
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,29 @@
+stages:
+  - generate
+  - publish
+
+generate-job:
+    stage: generate
+    tags:
+        - autoscale
+    variables:
+        REPO_METADATA_FILE: docs/includes/repo-metadata.md
+    script: >
+        echo "Created from: [$CI_PROJECT_NAMESPACE / $CI_PROJECT_TITLE]($CI_PROJECT_URL) Version: $(git describe --always)" > "$REPO_METADATA_FILE"
+    artifacts:
+        paths:
+            - "$REPO_METADATA_FILE"
+
+mark-job:
+    stage: publish
+    only:
+        - devel
+        - master
+    image: wsinpg/mark:latest
+    tags:
+        - autoscale
+    script: >
+        for f in $(find . -name includes -type d -prune -o -name README.md -prune -o -name '*.md' -print0 | xargs -0); do
+          echo 'username = ""' && echo "password = '$CONFLUENCE_PERSONAL_ACCESS_TOKEN'" | 
+            mark -c /dev/stdin -b https://ssg-confluence.internal.sanger.ac.uk -f "$f" --trace
+        done
diff --git a/Changes b/Changes
index 4e1c9d8e..6c344e20 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 LIST OF CHANGES
 
+ - docs
+   - Automatic confluence update for 'docs/api_usage.md', 'docs/instruments.md', 'docs/run_states.md', 'docs/user_management.md'
+
 release 101.2.0 (2024-05-24)
  - remove dependency on HTML::Tidy
  - update NovaSeqX icon
diff --git a/docs/api_usage.md b/docs/api_usage.md
index dbd2d6e3..00f342fe 100644
--- a/docs/api_usage.md
+++ b/docs/api_usage.md
@@ -1,3 +1,20 @@
+<!-- Space: NPG -->
+<!-- Parent: Tracking -->
+<!-- Title: API usage -->
+
+<!-- Macro: :box:([^:]+):([^:]*):(.+):
+     Template: ac:box
+     Icon: true
+     Name: ${1}
+     Title: ${2}
+     Body: ${3} -->
+
+:box:info:Note:This page is automatically generated; any edits will be overwritten:
+
+###### Repository information
+
+<!-- Include: docs/includes/repo-metadata.md -->
+
 # NPG Tracking API usage
 
 There are two APIs in active use for NPG Tracking: once Clearpress based, the other DBIx::Class based.
diff --git a/docs/includes/repo-metadata.md b/docs/includes/repo-metadata.md
new file mode 100644
index 00000000..2c8200af
--- /dev/null
+++ b/docs/includes/repo-metadata.md
@@ -0,0 +1 @@
+Created from: -  Version: -
diff --git a/docs/instruments.md b/docs/instruments.md
index 1533bb64..139ef493 100644
--- a/docs/instruments.md
+++ b/docs/instruments.md
@@ -1,3 +1,20 @@
+<!-- Space: NPG -->
+<!-- Parent: Tracking -->
+<!-- Title: All About Illumina Instruments -->
+
+<!-- Macro: :box:([^:]+):([^:]*):(.+):
+     Template: ac:box
+     Icon: true
+     Name: ${1}
+     Title: ${2}
+     Body: ${3} -->
+
+:box:info:Note:This page is automatically generated; any edits will be overwritten:
+
+###### Repository information
+
+<!-- Include: docs/includes/repo-metadata.md -->
+
 # All About Illumina Instruments
 
 ## Create Instrument
diff --git a/docs/run_states.md b/docs/run_states.md
index b15226bf..6171036d 100644
--- a/docs/run_states.md
+++ b/docs/run_states.md
@@ -1,3 +1,20 @@
+<!-- Space: NPG -->
+<!-- Parent: Tracking -->
+<!-- Title: Run States -->
+
+<!-- Macro: :box:([^:]+):([^:]*):(.+):
+     Template: ac:box
+     Icon: true
+     Name: ${1}
+     Title: ${2}
+     Body: ${3} -->
+
+:box:info:Note:This page is automatically generated; any edits will be overwritten:
+
+###### Repository information
+
+<!-- Include: docs/includes/repo-metadata.md -->
+
 # Run States
 
 The Tracking interface shows a sequence of states for Illumina runs. They have the following meanings in approximate order of execution:
diff --git a/docs/user_management.md b/docs/user_management.md
index 7710c286..e250de3f 100644
--- a/docs/user_management.md
+++ b/docs/user_management.md
@@ -1,3 +1,20 @@
+<!-- Space: NPG -->
+<!-- Parent: Tracking -->
+<!-- Title: User Management -->
+
+<!-- Macro: :box:([^:]+):([^:]*):(.+):
+     Template: ac:box
+     Icon: true
+     Name: ${1}
+     Title: ${2}
+     Body: ${3} -->
+
+:box:info:Note:This page is automatically generated; any edits will be overwritten:
+
+###### Repository information
+
+<!-- Include: docs/includes/repo-metadata.md -->
+
 # How to give users the permissions to set up a run 
 Users that use the NPG pipeline could ask, through a ticket, to be 
 granted some permissions to set up runs.