Forked from StanleyMasinde/sample_ssh_deploy_actions.yml
Created
October 25, 2023 13:39
-
-
Save Tonyce/de111beab22c8f277b6c98949ffb3a41 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