forked from darwinia-network/crab-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request darwinia-network#86 from darwinia-network/better-ci
Bettter CI
- Loading branch information
Showing
2 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
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
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 }} | ||
|
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
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 }} |