Fix CI deploy job (#8) #16
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 | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-deploy: | |
name: Build and deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install NPM dependencies | |
run: npm install | |
- name: Build using NPM | |
run: npm run build | |
- name: Setup SSH | |
env: | |
SSH_KEY_PUBLIC: ${{ secrets.SSH_KEY_PUBLIC }} | |
SSH_KEY_PRIVATE: ${{ secrets.SSH_KEY_PRIVATE }} | |
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }} | |
run: | | |
cd | |
mkdir -m 700 .ssh | |
cd .ssh | |
echo "$SSH_KEY_PUBLIC" > id_rsa.pub | |
chmod 644 id_rsa.pub | |
echo "$SSH_KEY_PRIVATE" > id_rsa | |
chmod 600 id_rsa | |
echo "$SSH_KNOWN_HOSTS" > known_hosts | |
chmod 600 known_hosts | |
- name: Upload build to server | |
env: | |
SSH_HOST: ${{ secrets.SSH_HOST }} | |
run: scp -r build/ "ci@${SSH_HOST}:/var/www/www.matbadev.com-${GITHUB_RUN_NUMBER}/" | |
- name: Activate uploaded build | |
env: | |
SSH_HOST: ${{ secrets.SSH_HOST }} | |
run: ssh -t "ci@${SSH_HOST}" "ln -sfn www.matbadev.com-${GITHUB_RUN_NUMBER} /var/www/www.matbadev.com" |