Skip to content

Commit

Permalink
Merge pull request darwinia-network#86 from darwinia-network/better-ci
Browse files Browse the repository at this point in the history
Bettter CI
  • Loading branch information
1022ranji authored Jan 18, 2022
2 parents fe676fc + 4f1cbea commit 23ef785
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/deploy-prd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Deploy production

on:
push:
tags:
- 'v*'

jobs:
deploy-develop:
name: Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: '14'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install

- name: Build
run: yarn build

- name: Prepare Project Config
run: |
mv vercel.json build/
- name: Deploy
id: deploy
run: |
REPO_NAME=${GITHUB_REPOSITORY#*/}
mv build $REPO_NAME
cd $REPO_NAME
vercel --token ${{ secrets.VERCEL_TOKEN }} --scope itering link --confirm
vercel --token ${{ secrets.VERCEL_TOKEN }} --scope itering deploy --prod | tee deploy.log
content=$(cat deploy.log)
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo ''
echo "::set-output name=VERCEL_OUTPUT::$content"
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: darwinia-docs-edu
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://avatars.githubusercontent.com/u/14985020?s=48&v=4
SLACK_MESSAGE: '${{ steps.deploy.outputs.VERCEL_OUTPUT }}'
SLACK_TITLE: Preview
SLACK_USERNAME: Vercel
SLACK_WEBHOOK: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }}

63 changes: 63 additions & 0 deletions .github/workflows/deploy-stg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy staging

on:
push:

jobs:
deploy-develop:
name: Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: '14'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install

- name: Build
run: yarn build

- name: Prepare Project Config
run: |
mv vercel.json build/
- name: Deploy
id: deploy
run: |
REPO_NAME=${GITHUB_REPOSITORY#*/}
mv build $REPO_NAME
cd $REPO_NAME
vercel --token ${{ secrets.VERCEL_TOKEN }} --scope itering link --confirm
vercel --token ${{ secrets.VERCEL_TOKEN }} --scope itering deploy | tee deploy.log
content=$(cat deploy.log)
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo ''
echo "::set-output name=VERCEL_OUTPUT::$content"
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: darwinia-docs-edu
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://avatars.githubusercontent.com/u/14985020?s=48&v=4
SLACK_MESSAGE: '${{ steps.deploy.outputs.VERCEL_OUTPUT }}'
SLACK_TITLE: Preview
SLACK_USERNAME: Vercel
SLACK_WEBHOOK: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }}

0 comments on commit 23ef785

Please sign in to comment.