Cleanup and actions update #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: Deploy to EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
name: Build service | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone Repository | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: true | |
- name: Install Node.JS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.18.2 | |
- name: Install yarn globally | |
run: npm install -g yarn | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
- name: Setting up dependency Cache | |
uses: actions/cache@v4 | |
id: yarn-cache | |
with: | |
path: ./node_modules | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: ${{ runner.os }}-yarn- | |
- name: Installing Dependencies | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
run: yarn --immutable | |
- name: Build service | |
run: yarn build | |
- name: Deploy Changes | |
run: | | |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key | |
scp -r ./dist ${USER_NAME}@${HOSTNAME}:/home/ec2-user/auto-presence | |
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} ' | |
ls | |
' | |