Created
May 26, 2022 02:21
-
-
Save mrgrain/f43102719cb48b81150111306e5a71ec to your computer and use it in GitHub Desktop.
GitHub Action to deploy files via ssh/rsync
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 via ssh | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Node.js packages | |
run: npm ci | |
- name: Build | |
run: npm run-script build | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: assets | |
path: .out/ | |
if-no-files-found: error | |
deploy: | |
needs: build | |
name: Deploy to Server | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Install SSH Key | |
run: | | |
install -m 600 -D /dev/null ~/.ssh/id_rsa | |
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | |
echo "$SSH_FINGERPRINT" >> ~/.ssh/known_hosts | |
chmod 600 ~/.ssh/known_hosts | |
shell: bash | |
env: | |
SSH_FINGERPRINT: ${{secrets.SSH_FINGERPRINT}} | |
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}} | |
- uses: actions/download-artifact@v2 | |
with: | |
name: assets | |
- name: Upload files | |
run: rsync --archive --verbose --stats . ${{secrets.SSH_DESTINATION}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment