Skip to content

Instantly share code, notes, and snippets.

@vickoman
Created March 14, 2019 02:58
Show Gist options
  • Save vickoman/1e0c37a67a181f5726b72ec1dd729eae to your computer and use it in GitHub Desktop.
Save vickoman/1e0c37a67a181f5726b72ec1dd729eae to your computer and use it in GitHub Desktop.
## Widget Composer Front pipeline
## Define the process
jobs:
- name: production-front
build_logs_to_retain: 5
serial: true
plan:
## Trigger slack alarm
- put: notify
params:
alert_type: started
## Get widget composer
- get: front
passed: []
trigger: false
## Build the App
- task: build-npm
config:
platform: linux
image_resource:
type: docker-image
source:
repository: parboleda/node-knowbly
inputs:
- name: front
params:
SDK_URL: ((credentials.env.production.front.sdk-url))
EXPORT_ROOT: ((credentials.env.production.front.export-root))
API_DATA_ROOT_SDK: ((credentials.env.production.front.api-data-root-sdk))
EXPORT_COURSE_ROOT: ((credentials.env.production.front.export-course-root))
FILESTACK_APIKEY: ((credentials.env.production.front.filestack-apikey))
FROALA_KEY: ((credentials.env.production.front.froala-key))
SENTRY_ENVIRONMENT: ((credentials.env.production.front.sentry-environment))
WIDGET_VERSIONS_VISIBLE: ((credentials.env.production.front.widget-versions-visible))
GA_UA: ((credentials.env.production.front.ga-ua))
API_WEBSOCKETS: ((credentials.env.production.front.api-websockets))
IS_PRODUCTION: ((credentials.env.production.front.is-production))
LAUNCH_DARKLY_KEY: ((credentials.env.production.front.launch_darkly_key))
# run:
# path: front/build.sh
run:
path: sh
args:
- -exc
- |
cd front
## Install NVM to setup our selected node and npm version
curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
## Apply nvm configuration
cat /root/.profile
. /root/.profile
## Run update
apt-get update
apt-get install man -y
## Install NVM
nvm install v8.11.1
nvm use v8.11.1
## Display all env variables
printenv
## remove package-lock.json
rm -f package-lock.json
## Install node-modules
npm i --quiet
## Copy Flags
cp ./config/devFlags.default.js ./config/devFlags.js
## Build project
npm run build --quiet
ls -al
## Copy dist folder to the output directory
cp -R ./dist ../build-output
ls ../build-output/dist
## Install ZIP
apt-get install zip
## Install jq and parse json
apt-get install -y jq
jq --version
echo ((credentials.backup))-front-$(jq -r .version package.json)
## Store artifact on s3
## With versioned S3 file
# zip -r prod-front.zip dist
# cp ./prod-front.zip ../build-output
## With regex
zip -r ((credentials.backup))-front-$(jq -r .version package.json).zip dist
cp ./((credentials.backup))-front-$(jq -r .version package.json).zip ../build-output
ls ../build-output
outputs:
- name: build-output
## Store current build on S3
- put: release-backup
params:
path: build-output
file: build-output/((credentials.backup))-front-*.zip
# acl: public-read
## Push dist to PCF
- put: deploy-to-PCF
params:
manifest: build-output/dist/prod-manifest.yml
path: build-output/dist
on_success:
put: notify
params:
alert_type: success
on_failure:
put: notify
params:
alert_type: failed
on_abort:
put: notify
params:
alert_type: aborted
## Job rollback
- name: rollback
serial: true
plan:
## Get the zip from s3
- get: release-backup
# Trigger slack alarm
- put: notify
params:
alert_type: started
message: Completed
## Build the App
- task: unpack-build
config:
platform: linux
image_resource:
type: docker-image
source:
repository: parboleda/node-knowbly
inputs:
- name: release-backup
run:
path: sh
args:
- -exc
- |
apt-get update
apt-get install zip
cd release-backup
unzip ((credentials.backup))-front-*.zip
rm ((credentials.backup))-front-*.zip
cp -R ./dist ../build-output
ls ../build-output/dist
outputs:
- name: build-output
- put: deploy-to-PCF
params:
manifest: build-output/dist/prod-manifest.yml
path: build-output/dist
on_success:
put: notify
params:
alert_type: success
on_failure:
put: notify
params:
alert_type: failed
on_abort:
put: notify
params:
alert_type: aborted
## Define Resource Types
resource_types:
## Slack Alerts
- name: slack-alert
type: docker-image
source:
repository: arbourd/concourse-slack-alert-resource
## Define Resources
resources:
## Slack notification
- name: notify
type: slack-alert
source:
url: ((credentials.slack.webhook-url))
## CF auth credentials
- name: deploy-to-PCF
type: cf
source:
api: ((credentials.cf.api))
organization: ((credentials.cf.organization))
password: ((credentials.cf.user.pass))
space: ((credentials.cf.space.prod))
username: ((credentials.cf.user.name))
skip_cert_check: false
## Knowbly Front
- name: front
type: git
source:
branch: ((credentials.git.branch.front))
uri: ((credentials.git.uri.front))
username: ((credentials.git.user.name))
password: ((credentials.git.user.pass))
## S3 Backup
- name: release-backup
type: s3
source:
bucket: ((credentials.aws.bucket))
access_key_id: ((credentials.aws.access-key-id))
secret_access_key: ((credentials.aws.secret-access-key))
regexp: ((credentials.backup))-front-(.*).zip
region_name: us-west-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment