Merge pull request #1632 from 2anki/dependabot/npm_and_yarn/nodemon-3… #915
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
name: Deploy to 2anki.net | |
on: | |
push: | |
paths-ignore: | |
- '**.md' | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: main | |
concurrency: 'production' | |
steps: | |
- name: SSH and run script | |
uses: appleboy/[email protected] | |
with: | |
host: 2anki.net | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
mkdir -pv /tmp/workspaces | |
node --version | |
TMP_BUILD_DIR=`mktemp` | |
WEB_DIR=~/src/github.com/2anki/web | |
CREATE_DECK_DIR=~/src/github.com/2anki/create_deck | |
SERVER_DIR=~/src/github.com/2anki/2anki.net | |
git -C ${SERVER_DIR} clean -fd | |
git -C ${WEB_DIR} clean -fd | |
git -C ${SERVER_DIR} stash | |
git -C ${WEB_DIR} stash | |
git -C ${CREATE_DECK_DIR} pull origin | |
git -C ${SERVER_DIR} pull origin | |
git -C ${WEB_DIR} pull origin | |
git -C ${SERVER_DIR} clean -fd | |
npm --prefix ${WEB_DIR} install | |
npm --prefix ${SERVER_DIR} install | |
pip install -r ${CREATE_DECK_DIR}/requirements.txt | |
rm -r ${TMP_BUILD_DIR} | |
npm --prefix ${SERVER_DIR} run build | |
BUILD_PATH=${TMP_BUILD_DIR} npm --prefix ${WEB_DIR} run build | |
rsync -avh ${TMP_BUILD_DIR} ${WEB_DIR} --delete | |
cd ${SERVER_DIR}/.. | |
pm2 restart server |