Created
February 9, 2023 08:55
-
-
Save StanleyMasinde/664259220501a8bdfa7b2a162d65e815 to your computer and use it in GitHub Desktop.
This file contains hidden or 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: | |
- main | |
- master | |
pull_request: | |
branches: | |
- main | |
- master | |
jobs: | |
production: | |
runs-on: ubuntu-latest | |
environment: | |
name: production | |
url: https://example.com | |
steps: | |
- name: Checkout π | |
uses: actions/checkout@master | |
- name: Install dependencies π¨π»βπ» | |
run: npm i | |
- name: Build for production ποΈ | |
run: npm run build | |
- name: Setup SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "${{ secrets.SSH_PRIV_KEY }}" > ~/.ssh/id_rsa | |
echo "${{ secrets.SSH_PUB_KEY }}" > ~/.ssh/id_rsa.pub | |
chmod 600 ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa.pub | |
ssh-keyscan -H ${{ secrets.IP }} >> ~/.ssh/known_hosts | |
- name: copy builds to server | |
run: | | |
rsync -vrm .output/* ${{ secrets.USER_IP }}:/var/www/example.com/ | |
ssh ${{ secrets.USER_IP }} "pm2 restart ecosystem.config.js" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment