add auto deploy #1
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: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.commits[0].message, '[ci-skip]')" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Add ssh key | |
run: | | |
mkdir ~/.ssh | |
echo "${{ secrets.OPENSSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan -H ${{ secrets.HOST }} >> ~/.ssh/known_hosts | |
- name: Build | |
run: | | |
npm install | |
npm run build | |
- name: Deploy files with rsync | |
run: | | |
rsync -z --delete .dist/ root@${{secrets.HOST}}:/var/www/about-me/ | |
- name: Clean up ssh files for some reason | |
run: | | |
rm ~/.ssh/id_rsa |