Skip to content

Commit

Permalink
chore(deploy): add deploy automatization (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
gizeasy authored Apr 4, 2022
1 parent c7d36d8 commit 8e65a2e
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 15 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Deploy

on:
push:
branches: master
pull_request:
types:
- opened
- reopened
- synchronize

env:
BUILD_SCRIPT: yarn build:storybook
BUILD_SCRIPT_OUTPUT: build
APP_NAME: rc-tree-adapter

jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Делаем checkout текущей ветки
- uses: actions/checkout@master
# Устанавливаем Node.JS для сборки приложения
- uses: actions/setup-node@v1
with:
node-version: '12'

- name: Install yarn
id: yarn-setup
run: |
yarn policies set-version 1.19.1
echo "::set-output name=cache_dir::$(yarn cache dir)"
- name: Настройка кэширования yarn
uses: actions/cache@v2
with:
path: ${{ steps.yarn-setup.outputs.cache_dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn --frozen-lockfile

# Записываем в переменные окружения имя текущей ветки
# Чтобы избежать конфиликтов с URL, меняем точки на _, а слеши на минусы
- name: Get branch name
shell: bash
run: |
echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g' | sed 's/\./_/g')" >> $GITHUB_ENV
# Собираем приложение
- name: Build Appliction
run: $BUILD_SCRIPT
# Доставляем собранное приложение на сервер
- name: Deploy to Server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEPLOY_SERVER_HOST }}
username: ${{ secrets.DEPLOY_SERVER_USERNAME }}
key: ${{ secrets.DEPLOY_SERVER_KEY }}
source: ${{ env.BUILD_SCRIPT_OUTPUT }}
target: /var/www/${{ env.APP_NAME }}/${{ env.BRANCH_NAME }}
strip_components: 1
overwrite: true
rm: true
- name: Print Info
run: echo "🎉 Deployed at http://${{env.BRANCH_NAME}}.${{env.APP_NAME}}.${{secrets.DEPLOY_DOMAIN}}"

- name: Add comment
if: ${{ github.event_name == 'pull_request'}}
uses: allthatjazzleo/actions-pull-request-add-comment@master
with:
message: '🎉 **Deployed at** http://${{env.BRANCH_NAME}}.${{env.APP_NAME}}.${{secrets.DEPLOY_DOMAIN}}'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build:docs": "cp README.md lib/README.md",
"build": "rm -rf lib && yarn build:css && yarn build:js && yarn build:types && yarn build:package.json && yarn build:docs",
"start": "NODE_ENV=development ROOT_PATH=./ NODE_PATH=./node_modules start-storybook -s public -p 6006 --ci",
"storybook:build": "NODE_ENV=production ROOT_PATH=./ NODE_PATH=./node_modules build-storybook -s public -o build/storybook",
"build:storybook": "NODE_ENV=production ROOT_PATH=./ NODE_PATH=./node_modules build-storybook -s public -o build",
"lint": "npm-run-all --parallel lint:*",
"format": "prettier --write '{src,types,scripts}/**/*.{json,{j,t}s{,x},css,}'",
"lint-fix": "npm-run-all format lint-fix:*",
Expand Down Expand Up @@ -96,8 +96,7 @@
"@babel/plugin-transform-react-jsx": "7.3.0",
"@babel/preset-typescript": "7.10.4",
"@consta/uikit": ">= 3.9.3",
"@consta/widgets-configs": "1.5.0",
"@consta/widgets-utils": "0.2.14",
"@consta/widgets-configs": "1.5.1",
"@emotion/styled-base": "10",
"@mdx-js/loader": "1.5.9",
"@storybook/addon-actions": "5.3.19",
Expand Down Expand Up @@ -140,8 +139,5 @@
"storybook-addon-smart-knobs": "6.0.2",
"storybook-addon-themes": "5.4.1",
"webpack-merge": "4.2.2"
},
"engines": {
"yarn": ">=1.19.1"
}
}
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2357,10 +2357,10 @@
react-transition-group "^4.4.1"
tslib "^2.1.0"

"@consta/widgets-configs@1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@consta/widgets-configs/-/widgets-configs-1.5.0.tgz#19e51ec9328d614825a8b53bfdc9cae5ff9b385c"
integrity sha512-t4ydsYScaC1nqLsuGbnM57+Grw3YOml8tp9vG24iBzXw4dVpqEfu5mb+nfcZ2WyKxxH6lLMdHLYqt/gQzeJHhA==
"@consta/widgets-configs@1.5.1":
version "1.5.1"
resolved "https://registry.yarnpkg.com/@consta/widgets-configs/-/widgets-configs-1.5.1.tgz#e2075bfe42a4340566709e56863fcf51699c3536"
integrity sha512-OUdCln4YBn5a7+Aj7VgGcs6mSeFwjsN1RlJigWNKwPmjlhSw6F/P4pje7i6PZpFpXobd81xle/HR2HKncWRpnQ==
dependencies:
"@babel/core" "7.4.5"
"@babel/plugin-proposal-class-properties" "7.4.4"
Expand Down Expand Up @@ -2433,11 +2433,6 @@
webpack-cli "3.3.9"
webpack-merge "4.2.1"

"@consta/widgets-utils@0.2.14":
version "0.2.14"
resolved "https://registry.yarnpkg.com/@consta/widgets-utils/-/widgets-utils-0.2.14.tgz#e06b2461b69cbe89ef49470b6a8754d23361dfb2"
integrity sha512-ZBoX148PIDN13hotbH4cgQmqJo2DrYQ6UM1t7iFzHirbQeN+CtRUm9CBfY8necBLjG2URA1NT3n5a9bN2FOILA==

"@csstools/convert-colors@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"
Expand Down

0 comments on commit 8e65a2e

Please # to comment.