From 6138ed20f0ee2782e688602876e743819a75afb0 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 16 Nov 2020 14:40:51 -0500 Subject: [PATCH] ci(backport-1.8): publish static assets (#9166) * ci:add check for bindata_assetfs changes (#8712) Co-authored-by: John Cowen Co-authored-by: hashicorp-ci * Merge pull request #8776 from hashicorp/ci/fix-auto-bindata commit a new bindata file if there are changes * add git config for static assets (#8777) * add commit sha to static-asset auto commit * ci: fix bindata autoupdate (#8801) * update bindata on ui-v2/ changes * ci: publish bindata_assetfs.go for all release/.x branches (#9158) Co-authored-by: Alvin Huang <17609145+alvin-huang@users.noreply.github.com> Co-authored-by: John Cowen Co-authored-by: hashicorp-ci Co-authored-by: Daniel Nephin --- .circleci/config.yml | 40 +++++++++++++++++++++++++++++++++++-- ui-v2/config/environment.js | 10 +++++----- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b25e151e2c..c5c2b36aec 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -548,6 +548,36 @@ jobs: paths: - ./agent/bindata_assetfs.go + # commits static assets to git + publish-static-assets: + docker: + - image: *GOLANG_IMAGE + steps: + - checkout + - add_ssh_keys: # needs a key to push updated static asset commit back to github + fingerprints: + - "c9:04:b7:85:bf:0e:ce:93:5f:b8:0e:68:8e:16:f3:71" + - attach_workspace: + at: . + - run: + name: commit agent/bindata_assetfs.go if there are UI changes + command: | + # check if there are any changes in ui-v2/ + # if there are, we commit the ui static asset file + # HEAD^! is shorthand for HEAD^..HEAD (parent of HEAD and HEAD) + if ! git diff --quiet --exit-code HEAD^! ui-v2/; then + git config --local user.email "hashicorp-ci@users.noreply.github.com" + git config --local user.name "hashicorp-ci" + + short_sha=$(git rev-parse --short HEAD) + git add agent/bindata_assetfs.go + git commit -m "auto-updated agent/bindata_assetfs.go from commit ${short_sha}" + git push origin master + else + echo "no UI changes so no static assets to publish" + fi + - run: *notify-slack-failure + # run ember frontend tests ember-test-oss: docker: @@ -717,7 +747,6 @@ workflows: - go-test-api: requires: [dev-build] - go-test-sdk: *filter-ignore-non-go-branches - build-distros: jobs: - check-vendor: *filter-ignore-non-go-branches @@ -739,6 +768,14 @@ workflows: - build-static-assets: requires: - ember-build-prod + - publish-static-assets: + filters: + branches: + only: + - master + - /release\/\d+\.\d+\.x$/ + requires: + - build-static-assets - dev-build: requires: - build-static-assets @@ -782,7 +819,6 @@ workflows: - envoy-integration-test-1.14.5: requires: - dev-build - website: jobs: - build-website-docker-image: diff --git a/ui-v2/config/environment.js b/ui-v2/config/environment.js index 1ee3c85f42..5ea317845e 100644 --- a/ui-v2/config/environment.js +++ b/ui-v2/config/environment.js @@ -1,7 +1,7 @@ 'use strict'; const fs = require('fs'); const path = require('path'); -module.exports = function(environment, $ = process.env) { +module.exports = function (environment, $ = process.env) { let ENV = { modulePrefix: 'consul-ui', environment, @@ -34,7 +34,7 @@ module.exports = function(environment, $ = process.env) { CONSUL_UI_DISABLE_REALTIME: typeof process.env.CONSUL_UI_DISABLE_REALTIME !== 'undefined', CONSUL_UI_DISABLE_ANCHOR_SELECTION: typeof process.env.CONSUL_UI_DISABLE_ANCHOR_SELECTION !== 'undefined', - CONSUL_COPYRIGHT_YEAR: (function(val) { + CONSUL_COPYRIGHT_YEAR: (function (val) { if (val) { return val; } @@ -45,7 +45,7 @@ module.exports = function(environment, $ = process.env) { .split('-') .shift(); })(process.env.CONSUL_COPYRIGHT_YEAR), - CONSUL_GIT_SHA: (function(val) { + CONSUL_GIT_SHA: (function (val) { if (val) { return val; } @@ -55,7 +55,7 @@ module.exports = function(environment, $ = process.env) { .toString() .trim(); })(process.env.CONSUL_GIT_SHA), - CONSUL_VERSION: (function(val) { + CONSUL_VERSION: (function (val) { if (val) { return val; } @@ -64,7 +64,7 @@ module.exports = function(environment, $ = process.env) { const contents = fs.readFileSync(version_go).toString(); return contents .split('\n') - .find(function(item, i, arr) { + .find(function (item, i, arr) { return item.indexOf('Version =') !== -1; }) .trim()