Skip to content

Feature1 #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
45 changes: 3 additions & 42 deletions .semaphore/client-deploy-build.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,33 @@
# Use the latest stable version of Semaphore 2.0 YML syntax:
version: v1.0

# Name your pipeline. In case you connect multiple pipelines with promotions,
# the name will help you differentiate between, for example, a CI build phase
# and delivery phases.
name: Semaphore JavaScript Example Pipeline

# An agent defines the environment in which your code runs.
# It is a combination of one of available machine types and operating
# system images.
# See https://docs.semaphoreci.com/article/20-machine-types
# and https://docs.semaphoreci.com/article/32-ubuntu-1804-image
agent:
machine:
type: e1-standard-2
os_image: ubuntu2004

# Blocks are the heart of a pipeline and are executed sequentially.
# Each block has a task that defines one or more jobs. Jobs define the
# commands to execute.
# See https://docs.semaphoreci.com/article/62-concepts
blocks:
- name: Install dependencies
task:
# Set environment variables that your project requires.
# See https://docs.semaphoreci.com/article/66-environment-variables-and-secrets
env_vars:
- name: NODE_ENV
value: production
- name: CI
value: 'true'
- name: REACT_APP_API_BASE_URL
value: "http://YOUR_CLUSTER_URL/v1/api"
# This block runs two jobs in parallel and they both share common
# setup steps. We can group them in a prologue.
# See https://docs.semaphoreci.com/article/50-pipeline-yaml#prologue
value: 'http://YOUR_CLUSTER_URL/v1/api'
prologue:
commands:
# Get the latest version of our source code from GitHub:
- checkout

# Use the version of Node.js specified in .nvmrc.
# Semaphore provides nvm preinstalled.
- nvm install 16.16.0
- nvm use
- node --version
- npm --version
jobs:
# First parallel job:
- name: client npm install and cache
commands:
- cd src/client

# Restore dependencies from cache.
# For more info on caching, see https://docs.semaphoreci.com/article/68-caching-dependencies
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
- 'cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master'
- npm run build

# Store the latest version of client build in cache to reuse in further blocks:
- cache store client-build-$SEMAPHORE_WORKFLOW_ID build

# The deployment pipeline is defined to run on manual approval from the UI.
# Semaphore will the time and the name of the person who promotes each
# deployment.
#
# You could, for example, add another promotion to a pipeline that
# automatically deploys to a staging environment from branches named
# after a certain pattern.
# https://docs.semaphoreci.com/article/50-pipeline-yaml#promotions
promotions:
- name: Deploy Client
pipeline_file: client-deploy.yml
18 changes: 3 additions & 15 deletions .semaphore/client-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
# This pipeline runs after semaphore.yml
version: v1.0
name: Client deploy
agent:
machine:
# Use a machine type with more RAM and CPU power for faster container
# builds:
type: e1-standard-2
os_image: ubuntu2004
blocks:
- name: Build
task:
# Set environment variables that your project requires.
# See https://docs.semaphoreci.com/article/66-environment-variables-and-secrets
env_vars:
- name: BUCKET_NAME
value: YOUR_APP_URL
# For info on creating secrets, see:
# https://docs.semaphoreci.com/article/66-environment-variables-and-secrets
secrets:
- name: gcr-secret
jobs:
- name: Deploy to Google Cloud Storage
commands:
# Authenticate using the file injected from the secret
- gcloud auth activate-service-account --key-file=.secrets.gcp.json
- gcloud config set project $GCP_PROJECT_ID
- gcloud config set compute/zone $GCP_PROJECT_DEFAULT_ZONE

# Restore build from cache.
- cache restore client-build-$SEMAPHORE_WORKFLOW_ID

# Deploy to Google Cloud Storage
- gsutil -m rsync -r build gs://$BUCKET_NAME
- gsutil iam ch allUsers:objectViewer gs://$BUCKET_NAME
- gsutil web set -m index.html -e 404.html gs://$BUCKET_NAME
- 'gsutil -m rsync -r build gs://$BUCKET_NAME'
- 'gsutil iam ch allUsers:objectViewer gs://$BUCKET_NAME'
- 'gsutil web set -m index.html -e 404.html gs://$BUCKET_NAME'
31 changes: 9 additions & 22 deletions .semaphore/secrets/gcr-secret.sample.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
# Copy this file into one without .sample part and then populate it with actual values.
# Then you can create secret, by using command
# `sem create -f path/to/this/file`
# More info https://docs.semaphoreci.com/article/66-environment-variables-and-secrets
version: v1.0
name: ''
agent:
machine:
type: e1-standard-2
os_image: ubuntu2004
apiVersion: v1alpha
kind: Secret
metadata:
# Use this name to create this secret manually
name: gcr-secret
data:
# If you haven't set up k8s on google you need to do it first
# Start with https://cloud.google.com/kubernetes-engine/docs/quickstart
# Play with it and then you can use it with this project.
# Check out https://docs.semaphoreci.com/article/72-google-container-registry-gcr as an example.
# Also check out https://docs.semaphoreci.com/article/119-ci-cd-for-microservices-on-kubernetes
# as example of k8s deploy.
env_vars:
# Id of your project
# More info here https://cloud.google.com/resource-manager/docs/creating-managing-projects?visit_id=636878590586351739-3388570778&rd=1#identifying_projects
- name: GCP_PROJECT_ID
value: "your-gcp-project-id"
# Default compute zone you've selected
# https://cloud.google.com/compute/docs/regions-zones/#available
value: your-gcp-project-id
- name: GCP_PROJECT_DEFAULT_ZONE
value: "europe-west1-b"
value: europe-west1-b
files:
# You need to create service account and export json key file for it here https://console.cloud.google.com/iam-admin/serviceaccounts
# to use in this file.
- path: .secrets.gcp.json
# Could be created by
# - `base64 -w 0 /path/to/file` and put in
# - upload in https://<your-namesace>.semaphoreci.com/secrets
content: PASTE_BASE64_ENCODED_CONTENT_HERE
blocks: []
24 changes: 9 additions & 15 deletions .semaphore/secrets/server-ormconfig-production-secret.sample.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
# Copy this file into one without .sample part and then populate it with actual values.
# Then you can create secret, by using command
# `sem create -f path/to/this/file`
# More info https://docs.semaphoreci.com/article/66-environment-variables-and-secrets
version: v1.0
name: ''
agent:
machine:
type: e1-standard-2
os_image: ubuntu2004
apiVersion: v1beta
kind: Secret
metadata:
# Use this name to create this secret manually
name: server-ormconfig-production
data:
files:
# Copy src/server/ormconfig.sample.json into ormconfig.production.json and populate with production values
# You will need production connection settings in this config file.
# In this eample heroku postgres database addon is used.
# You will need to create heroku app and then add addon https://elements.heroku.com/addons/heroku-postgresql
# Then you will be able to view database connection settings like described here https://devcenter.heroku.com/articles/heroku-postgresql#external-connections-ingress
- path: ormconfig.production.json
# Could be created by
# - `base64 -w 0 /path/to/file` and put in
# - upload in https://<your-namesace>.semaphoreci.com/secrets
content: PASTE_BASE64_ENCODED_CONTENT_HERE
- path: ormconfig.production.json
content: PASTE_BASE64_ENCODED_CONTENT_HERE
blocks: []
22 changes: 9 additions & 13 deletions .semaphore/secrets/server-production-env-secret.sample.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# Copy this file into one without .sample part and then populate it with actual values.
# Then you can create secret, by using command
# `sem create -f path/to/this/file`
# More info https://docs.semaphoreci.com/article/66-environment-variables-and-secrets
version: v1.0
name: ''
agent:
machine:
type: e1-standard-2
os_image: ubuntu2004
apiVersion: v1beta
kind: Secret
metadata:
# Use this name to create this secret manually
name: server-production-env
data:
files:
# Server production.env file doesn't exist by default, copy src/server/sample.env into src/server/production.env
# and populate with production values
# Then create secret - in the end it should be here - https://<put-your-namespace-here>.semaphoreci.com/secrets
- path: server-production.env
# Could be created by
# - `base64 -w 0 /path/to/file` and put in
# - upload in https://<your-namesace>.semaphoreci.com/secrets
content: PASTE_BASE64_ENCODED_CONTENT_HERE
- path: server-production.env
content: PASTE_BASE64_ENCODED_CONTENT_HERE
blocks: []
Loading