update CI #28
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 | |
on: | |
push: | |
branches: [ master ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
update-known-hosts: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Update SSH known hosts | |
run: | | |
ssh-keygen -R github.com | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
deploy: | |
runs-on: ubuntu-latest | |
needs: update-known-hosts | |
steps: | |
- name: Deploy app | |
uses: appleboy/[email protected] | |
with: | |
host: ${{secrets.SSH_HOST}} | |
key: ${{secrets.SSH_KEY}} | |
username: ${{secrets.SSH_USERNAME}} | |
script: | | |
set -e | |
appName=oculus-deals-spider | |
appDir=/opt/$appName | |
tempDir=$(mktemp -d /tmp/oculus-deals-spider.XXXXXXXXX) | |
rm -rf "$tempDir" # Remove existing temp directory if it exists | |
mkdir -p "$tempDir" # Recreate temp directory | |
cd $tempDir | |
git clone [email protected]:introkun/oculus-deals-spider.git . | |
echo "Installing app dependencies" | |
npm ci | |
echo "Writing config wile" | |
echo "${{vars.PROD_CONFIG}}" > config/production.json | |
echo "Renaming current app folder" | |
mv $appDir $appDir.$(date +\%Y\%m\%d\%H\%M\%S) | |
echo "Renaming new app to current" | |
cd /opt | |
mv $tempDir $appDir |