Skip to content

chore(ci): fix staging origin (#755) #1153

chore(ci): fix staging origin (#755)

chore(ci): fix staging origin (#755) #1153

Workflow file for this run

name: Client CI
on:
push:
paths:
- client/**
jobs:
test:
runs-on: ubuntu-latest
services:
test_mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 33060:3306
steps:
- uses: actions/checkout@v2
- name: use node v14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: cache node modules
uses: actions/cache@v2
with:
path: |
~/.cache
!~/.cache/exclude
**/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.OS }}-build-${{ env.cache-name }}
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: install server dependencies
working-directory: server
run: npm install
- name: create database
run: mysql --protocol=tcp --host=localhost --port=33060 --user=root --password=password -e "CREATE DATABASE test_meirim character set UTF8 collate utf8_bin; SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY,',''));"
- name: run migrations
env:
NODE_CONFIG: '{"database": {"connection": {"host": "localhost", "port": "33060", "user": "root", "password": "password", "database": "test_meirim"}}}'
working-directory: server
run: node node_modules/knex/bin/cli.js migrate:latest
- name: install client dependencies
working-directory: client
run: npm install
- name: build frontend
working-directory: client
run: npm run build
- name: get ethereal credentials
id: get_ethereal_credentials
run: |
response=$(curl -XPOST -d "{\"requestor\": \"meirim-test\", \"version\": \"0.0.1\"}" -H "Content-Type: application/json" https://api.nodemailer.com/user)
echo "::set-output name=user::$(echo $response | jq -r '.user')"
echo "::set-output name=pass::$(echo $response | jq -r '.pass')"
- name: serve
env:
NODE_CONFIG: '{"database": {"connection": {"host": "localhost", "port": "33060", "user": "root", "password": "password", "database": "test_meirim"}}, "email": {"templates": {"digestPlans": "d-db0b55ab042e4ba9878715acd35c1d6c"}, "options": {"host": "smtp.ethereal.email", "port": 587, "secure": false, "auth": {"user": "${{ steps.get_ethereal_credentials.outputs.user }}", "pass": "${{ steps.get_ethereal_credentials.outputs.pass }}"}}}}'
working-directory: server
run: |
npm run serve &
sleep 3
- name: e2e test
working-directory: client
run: |
$(npm bin)/cypress run --browser chrome --headless &&
$(npm bin)/cypress run --browser firefox --headless
build-and-deploy-staging:
environment: staging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: use node v14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: install client dependencies
working-directory: client
run: npm install
- name: build
working-directory: client
run: npm run build
env:
NODE_ENV: staging
BASE_NAME: ${{ github.ref_name }}
PUBLIC_URL: "https://staging.meirim.org/${{ github.ref_name }}"
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: staging.meirim.org
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CI_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CI_SECRET_KEY }}
SOURCE_DIR: "client/build"
DEST_DIR: ${{ github.ref_name }}
AWS_REGION: il-central-1
- name: info
run: |
echo "deployed to"
echo "https://staging.meirim.org/${{ github.ref_name }}"
build-and-deploy-prod:
environment: prod
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: use node v14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: install client dependencies
working-directory: client
run: npm install
- name: build
working-directory: client
run: npm run build
env:
PUBLIC_URL: "http://prod.meirim.org.s3-website.il-central-1.amazonaws.com"
NODE_ENV: production
- uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: prod.meirim.org
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CI_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CI_SECRET_KEY }}
SOURCE_DIR: "client/build"
AWS_REGION: il-central-1