Create test #2
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: Portfolio Deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deployment: | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: deploy | |
deploy: | |
runs-on: ubuntu-latest | |
needs: test # this job depends on "test" having finished | |
if: github.ref == 'refs/heads/main' # we tell Github to only execute this step if we're on our master branch (so we don't put unfinished branches in production) | |
steps: | |
- name: Deploying to AWS | |
uses: appleboy/ssh-action@master # An action made to control Linux servers | |
with: # We set all our secrets here for the action, these won't be shown in the action logs | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
port: ${{ secrets.PORT }} | |
script: | | |
cd ${{ secrets.APPDIR }} | |
git pull # we pull any changes from git | |
npm prune # we remove any unused dependencies | |
npm install # we install any missing dependencies | |
npm run build # we build our app | |
pm2 reload all # we reload the app via PM2 |