images #13
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs | |
name: Node.js CI | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "npm" | |
- run: npm install | |
- run: npm run build | |
- name: Deploy to EC2 | |
run: | | |
echo "${{ secrets.EC2_SSH_KEY }}" > /tmp/ssh_key | |
chmod 600 /tmp/ssh_key | |
rsync -avz -e "ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no" .output/ [email protected]:/home/ubuntu/studymate/.output | |
ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no [email protected] 'bash -c "source ~/.bashrc && source ~/.nvm/nvm.sh && pm2 restart all"' |