From 81d4e5c85d20034b0f4ea97abfe2e0fa790448e5 Mon Sep 17 00:00:00 2001
From: JP <77391175+joao-paulo-parity@users.noreply.github.com>
Date: Wed, 11 Jan 2023 06:03:07 -0300
Subject: [PATCH] Trigger update-node-template when a final release tag is
 created (#6522)

* trigger update-node-template when final release tag is created

ref https://github.com/paritytech/release-engineering/issues/142

* fix comment

* Update scripts/ci/gitlab/pipeline/publish.yml

Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com>

* fix regular expression

Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com>
---
 .../scripts/ci/gitlab/pipeline/publish.yml    | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/polkadot/scripts/ci/gitlab/pipeline/publish.yml b/polkadot/scripts/ci/gitlab/pipeline/publish.yml
index 3484fcae336..eed71f36f2b 100644
--- a/polkadot/scripts/ci/gitlab/pipeline/publish.yml
+++ b/polkadot/scripts/ci/gitlab/pipeline/publish.yml
@@ -214,3 +214,25 @@ publish-rustdoc:
     - echo "___Rustdoc was successfully published to https://paritytech.github.io/polkadot/___"
   after_script:
     - rm -rf .git/ ./*
+
+# Ref: https://github.com/paritytech/opstooling/issues/111
+update-node-template:
+  stage:                           publish
+  extends:                         .kubernetes-env
+  variables:
+    GIT_STRATEGY:          none
+  rules:
+    # The template is only updated for FINAL releases
+    # i.e. the rule should not cover RC or patch releases
+    - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+$/           # e.g. v1.0
+    - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/    # e.g. v1.0.0
+  script:
+    - git clone --depth=1 --branch="$PIPELINE_SCRIPTS_TAG" https://github.com/paritytech/pipeline-scripts
+    - export POLKADOT_BRANCH="polkadot-v$CI_COMMIT_TAG"
+    - git clone --depth=1 --branch="$POLKADOT_BRANCH" https://github.com/paritytech/substrate
+    - cd substrate
+    - ../pipeline-scripts/update_substrate_template.sh
+      --repo-name "substrate-node-template"
+      --template-path "bin/node-template"
+      --github-api-token "$GITHUB_TOKEN"
+      --polkadot-branch "$POLKADOT_BRANCH"
-- 
GitLab