|
| 1 | +# Use the latest stable version of Semaphore 2.0 YML syntax: |
| 2 | +version: v1.0 |
| 3 | + |
| 4 | +# Name your pipeline. In case you connect multiple pipelines with promotions, |
| 5 | +# the name will help you differentiate between, for example, a CI build phase |
| 6 | +# and delivery phases. |
| 7 | +name: Semaphore JavaScript Example Pipeline |
| 8 | + |
| 9 | +# An agent defines the environment in which your code runs. |
| 10 | +# It is a combination of one of available machine types and operating |
| 11 | +# system images. |
| 12 | +# See https://docs.semaphoreci.com/article/20-machine-types |
| 13 | +# and https://docs.semaphoreci.com/article/32-ubuntu-1804-image |
| 14 | +agent: |
| 15 | + machine: |
| 16 | + type: e1-standard-2 |
| 17 | + os_image: ubuntu1804 |
| 18 | + |
| 19 | +# Blocks are the heart of a pipeline and are executed sequentially. |
| 20 | +# Each block has a task that defines one or more jobs. Jobs define the |
| 21 | +# commands to execute. |
| 22 | +# See https://docs.semaphoreci.com/article/62-concepts |
| 23 | +blocks: |
| 24 | + - name: Install dependencies |
| 25 | + task: |
| 26 | + # Set environment variables that your project requires. |
| 27 | + # See https://docs.semaphoreci.com/article/66-environment-variables-and-secrets |
| 28 | + env_vars: |
| 29 | + - name: NODE_ENV |
| 30 | + value: production |
| 31 | + - name: CI |
| 32 | + value: 'true' |
| 33 | + |
| 34 | + # This block runs two jobs in parallel and they both share common |
| 35 | + # setup steps. We can group them in a prologue. |
| 36 | + # See https://docs.semaphoreci.com/article/50-pipeline-yaml#prologue |
| 37 | + prologue: |
| 38 | + commands: |
| 39 | + # Get the latest version of our source code from GitHub: |
| 40 | + - checkout |
| 41 | + |
| 42 | + # Use the version of Node.js specified in .nvmrc. |
| 43 | + # Semaphore provides nvm preinstalled. |
| 44 | + - nvm use |
| 45 | + - node --version |
| 46 | + - npm --version |
| 47 | + jobs: |
| 48 | + # First parallel job: |
| 49 | + - name: client npm install and cache |
| 50 | + commands: |
| 51 | + - cd src/client |
| 52 | + |
| 53 | + # Restore dependencies from cache. |
| 54 | + # For more info on caching, see https://docs.semaphoreci.com/article/68-caching-dependencies |
| 55 | + - cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master |
| 56 | + |
| 57 | + - npm run build |
| 58 | + # Store the latest version of node modules in cache to reuse in |
| 59 | + # further blocks: |
| 60 | + - cache store client-build-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json) build |
| 61 | + |
| 62 | +# The deployment pipeline is defined to run on manual approval from the UI. |
| 63 | +# Semaphore will the time and the name of the person who promotes each |
| 64 | +# deployment. |
| 65 | +# |
| 66 | +# You could, for example, add another promotion to a pipeline that |
| 67 | +# automatically deploys to a staging environment from branches named |
| 68 | +# after a certain pattern. |
| 69 | +# https://docs.semaphoreci.com/article/50-pipeline-yaml#promotions |
| 70 | +promotions: |
| 71 | + - name: Deploy Client |
| 72 | + pipeline_file: client-deploy.yml |
0 commit comments