Skip to content

Commit

Permalink
fix: Make and run script instead of executing command directly
Browse files Browse the repository at this point in the history
  • Loading branch information
JeongHeanKim committed Sep 21, 2023
1 parent d820c2c commit 5e47053
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 1 addition & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,7 @@ build_for_release:
before_script:
- npm ci --cache .npm --prefer-offline
script:
- >
TARGET='<script>(function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != "dataLayer" ? "&l=" + l : ""; j.async = true; j.src = "https:\/\/www.googletagmanager.com\/gtm.js?id=" + i + dl; f.parentNode.insertBefore(j, f); })(window, document, "script", "dataLayer", "GTM-W6T5HDN");<\/script> <noscript><iframe src="https:\/\/www.googletagmanager.com\/ns.html?id=GTM-W6T5HDN" height="0" width="0" style="display:none;visibility:hidden"><\/iframe><\/noscript><\/head>'
SOURCE='<\/head>'
sed -i.bak "s/$SOURCE/$TARGET/g" public/index.html
rm public/index.html.bak
- bash add_google_analytics_tag.sh
- npm run build
- cp -rp dist/* public
artifacts:
Expand Down
5 changes: 5 additions & 0 deletions add_google_analytics_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TARGET='<script>(function (w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != "dataLayer" ? "&l=" + l : ""; j.async = true; j.src = "https:\/\/www.googletagmanager.com\/gtm.js?id=" + i + dl; f.parentNode.insertBefore(j, f); })(window, document, "script", "dataLayer", "GTM-W6T5HDN");<\/script> <noscript><iframe src="https:\/\/www.googletagmanager.com\/ns.html?id=GTM-W6T5HDN" height="0" width="0" style="display:none;visibility:hidden"><\/iframe><\/noscript><\/head>'
SOURCE='<\/head>'

sed -i.bak "s/$SOURCE/$TARGET/g" public/index.html
rm public/index.html.bak

0 comments on commit 5e47053

Please sign in to comment.