Deploy Stage #94
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with Actions | |
name: Deploy Stage | |
# Controls when the workflow will run | |
on: | |
push: | |
branches: [stage] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# workflow_call: | |
# secrets: | |
# STAGE_CF_USERNAME: | |
# description: cf-login username | |
# required: true | |
# STAGE_CF_PASSWORD: | |
# description: cf-login password | |
# required: true | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: ${{ inputs.branch_name }} | |
# - uses: actions/cache@v2 | |
# with: | |
# path: ~/.npm | |
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
# restore-keys: | | |
# ${{ runner.os }}-node- | |
- uses: actions/cache@v2 | |
id: api-npm-cache | |
with: | |
path: ./api/node_modules/ | |
key: ${{ runner.os }}-api-npm-${{ hashFiles('./api/package-lock.json') }} | |
- uses: actions/cache@v2 | |
id: frontend-npm-cache | |
with: | |
path: ./frontend/node_modules/ | |
key: ${{ runner.os }}-frontend-npm-${{ hashFiles('./frontend/package-lock.json') }} | |
- uses: actions/cache@v2 | |
id: frontend-scss-cache | |
with: | |
path: ./frontend/src/styles/ | |
key: ${{ runner.os }}-frontend-scss-${{ hashFiles('./frontend/src/scss/**.scss') }} | |
# Notice that the cache for the frontend is actually in the api directory... | |
- uses: actions/cache@v2 | |
id: frontend-src-cache | |
with: | |
path: ./api/src/client | |
key: ${{ runner.os }}-frontend-src-${{ hashFiles('./frontend/src/**/*', './frontend/package.json') }} | |
# Build frontend (requires node 12) | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: "12" | |
- name: Install frontend dependencies | |
if: steps.frontend-npm-cache.outputs.cache-hit != 'true' | |
run: npm ci | |
working-directory: frontend | |
- name: Build frontend styles | |
if: steps.frontend-scss-cache.outputs.cache-hit != 'true' | |
run: npm run build:styles | |
working-directory: frontend | |
- name: Build frontend | |
if: steps.frontend-src-cache.outputs.cache-hit != 'true' | |
run: npm run build:stage | |
working-directory: frontend | |
# Build backend (requires node 14) | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: "14" | |
- name: Install dependencies | |
if: steps.api-npm-cache.outputs.cache-hit != 'true' | |
run: npm ci | |
working-directory: api | |
# Because of how the deploy works, do not cache backend | |
# frontend changes _will not_ make it if that's the case | |
- name: Build backend | |
run: npm run build | |
working-directory: api | |
# - name: Update Login.gov creds on cloud.gov | |
# uses: cloud-gov/cg-cli-tools@main | |
# with: | |
# cf_api: https://api.fr.cloud.gov | |
# cf_username: ${{secrets.STAGE_CF_USERNAME}} | |
# cf_password: ${{secrets.STAGE_CF_PASSWORD}} | |
# cf_org: gsa-open-opportunities | |
# cf_space: USDS | |
# cf_command: cf set-env smeqa-staging LOGIN_KEY "${{secrets.STAGE_LOGIN_KEY_11_22_21}}" | |
- name: Deploy to cloud.gov | |
uses: cloud-gov/cg-cli-tools@main | |
with: | |
cf_api: https://api.fr.cloud.gov | |
cf_username: ${{secrets.STAGE_CF_USERNAME}} | |
cf_password: ${{secrets.STAGE_CF_PASSWORD}} | |
cf_org: gsa-open-opportunities | |
cf_space: USDS | |
cf_manifest: deployStage.yml |