Skip to content

Commit

Permalink
Problem: (fix crypto-com#175) workflow to deploy by merging pr, dev a…
Browse files Browse the repository at this point in the history
…nd master … (crypto-com#176)

Solution:
	1. Deployment of staging: comment "/RUN" in PR only by limited collaborators i.e tomas and lesile, etc.
	2. Deployment of production: only happen when merge to master
Co-authored-by: Calvin Lau <[email protected]>
  • Loading branch information
allthatjazzleo and calvinlauyh authored Jul 15, 2020
1 parent 984ade9 commit 70326b1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
31 changes: 28 additions & 3 deletions .github/workflows/chain-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,44 @@ name: chain-docs

on:
push:
branches: [ dev , master ]
branches: [ master ]
paths:
- 'docs/**'
- 'ci/**'
- '!README.md'
issue_comment:
types: [created, edited]
jobs:

build:
name: Build
runs-on: ubuntu-latest
if: github.event_name == 'push' || (github.event.comment.body == '/staging' && (github.actor == 'allthatjazzleo' || github.actor == 'tomtau' || github.actor == 'lezzokafka' || github.actor == 'yihuang' || github.actor == 'calvinlauco' || github.actor == 'foreseaz' || github.actor == 'CeruleanAtMonaco' || github.actor == 'devashishdxt' || github.actor == 'leejw51crypto'))
steps:
- name: Check out code
- name: Github API Request
id: request
uses: octokit/[email protected]
if: github.event_name == 'issue_comment'
with:
route: ${{ github.event.issue.pull_request.url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get PR informations
id: pr_data
if: github.event_name == 'issue_comment'
run: |
echo "::set-output name=branch::${{ fromJson(steps.request.outputs.data).head.ref }}"
echo "::set-output name=repo_name::${{ fromJson(steps.request.outputs.data).base.repo.full_name }}"
- name: Checkout PR Branch
uses: actions/checkout@v2
if: github.event_name == 'issue_comment'
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ steps.pr_data.outputs.repo_name }}
ref: ${{ steps.pr_data.outputs.branch }}
- name: Check MASTER code
uses: actions/checkout@v2
if: github.event_name == 'push'
- uses: actions/setup-node@v1
with:
node-version: '12'
Expand All @@ -25,6 +50,7 @@ jobs:
MASTER_BUCKET_NAME: ${{ secrets.MASTER_BUCKET_NAME }}
MASTER_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.MASTER_CLOUDFRONT_DISTRIBUTION_ID }}
MASTER_REGION: ${{ secrets.MASTER_REGION }}
EVENT: ${{ github.event_name }}
STAGING_AWS_ACCESS_KEY_ID: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }}
STAGING_AWS_SECRET_ACCESS_KEY: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }}
STAGING_BUCKET_NAME: ${{ secrets.STAGING_BUCKET_NAME }}
Expand All @@ -45,7 +71,6 @@ jobs:
# Scan auto-detects the languages in your project. To override uncomment the below variable and set the type
# type: credscan,java
# type: python

- name: Upload report
uses: github/codeql-action/upload-sarif@v1
with:
Expand Down
6 changes: 4 additions & 2 deletions ci/scripts/prepare
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -e

BRANCH=$(echo ${GITHUB_REF##*/} | tr '[:lower:]' '[:upper:]')
if [ "${BRANCH}" == "DEV" ]
if [ "${EVENT}" == "push" ]
then
BRANCH="MASTER"
elif [ "${EVENT}" == "issue_comment" ]
then
BRANCH="STAGING"
fi
Expand Down

0 comments on commit 70326b1

Please sign in to comment.