From 70326b133bfec3be458d0ceefc4e51854aba3d88 Mon Sep 17 00:00:00 2001 From: allthatjazzleo <34628052+allthatjazzleo@users.noreply.github.com> Date: Wed, 15 Jul 2020 16:48:06 +0800 Subject: [PATCH] =?UTF-8?q?Problem:=20(fix=20#175)=20workflow=20to=20deplo?= =?UTF-8?q?y=20by=20merging=20pr,=20dev=20and=20master=20=E2=80=A6=20(#176?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .github/workflows/chain-docs.yml | 31 ++++++++++++++++++++++++++++--- ci/scripts/prepare | 6 ++++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/chain-docs.yml b/.github/workflows/chain-docs.yml index 5cd24ead..9d400808 100644 --- a/.github/workflows/chain-docs.yml +++ b/.github/workflows/chain-docs.yml @@ -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/request-action@v2.0.0 + 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' @@ -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 }} @@ -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: diff --git a/ci/scripts/prepare b/ci/scripts/prepare index 96c4d2ae..399899a4 100755 --- a/ci/scripts/prepare +++ b/ci/scripts/prepare @@ -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