Skip to content

Commit b527e71

Browse files
authored
Update main.yml
1 parent c34b22a commit b527e71

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
# Be aware, in this example this job updates the server on pull request, so either move it to another worflow, either remove pull request trigger above
5353
deploy:
5454
runs-on: ubuntu-latest
55-
needs: [test]
55+
needs: [test] # do not update if tests fail
5656
steps:
5757
- uses: actions/checkout@v2
5858
- uses: actions/setup-node@v2-beta
@@ -76,19 +76,15 @@ jobs:
7676
name: dist
7777
path: |
7878
dist
79-
- name: copy static files to destination server
80-
uses: garygrossgarten/github-action-scp@release
81-
with:
82-
local: dist
83-
remote: /srv/http/vue/dist
84-
# In order for credentials to work you need to put them into github settings https://github.com/USERNAME/REPOSITORY/settings/actions
85-
# Check credentials description in https://github.com/garygrossgarten/github-action-scp
86-
# I prefer using new pair of ssh keys, instead of exposing password to github
87-
# Generate new keypair with: ssh-keygen -t rsa -b 4096 -C "vue-webpack-typescript-github-actions" -f /tmp/id_rsa
88-
# Put /tmp/id_rsa.pub into server ~/.ssh/authorized_keys
89-
# And /tmp/id_rsa.pub into github secrets with key ID_RSA (link is above)
90-
# Also create github secret with keys HOST, PORT (default is 22), SSH_USER
91-
host: ${{ secrets.HOST }}
92-
port: ${{ secrets.PORT }}
93-
username: ${{ secrets.SSH_USER }}
94-
privateKey : ${{ secrets.ID_RSA }}
79+
- name: Setup ssh
80+
run: |
81+
mkdir -p ~/.ssh
82+
echo "${{ secrets.ID_RSA }}" > ~/.ssh/id_rsa
83+
chmod 600 ~/.ssh/id_rsa
84+
ssh-keyscan -p ${{ secrets.PORT }} ${{ secrets.HOST }} >> ~/.ssh/known_hosts
85+
- name: Copy static files to destination server
86+
# Copying files by packing them into non-compress archive is a lot faster. It takes 8 seconds to copy all files instead of 4 minutes with packages like garygrossgarten/github-action-scp@release
87+
run: |
88+
cd frontend
89+
tar c dist/ | ssh ${{ secrets.SSH_USER }}@${{ secrets.HOST }} -p ${{ secrets.PORT }} "rm -rf /srv/http/vue/dist && tar x -C /srv/http/vue/"
90+

0 commit comments

Comments
 (0)