Skip to content

Commit

Permalink
Create and populate SSH Key and upload website build to remote server
Browse files Browse the repository at this point in the history
  • Loading branch information
ctmbl committed Oct 25, 2023
1 parent 6a323a0 commit cba404b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
name: build
path: ./build/blog

# Deployment job: heavily inspired from https://swharden.com/blog/2022-03-20-github-actions-hugo/
# /!\ only triggers on push events
deploy:
needs: [build]
if: ${{ github.event_name == 'push' }}
Expand All @@ -51,3 +53,21 @@ jobs:
with:
name: build
path: build/blog

# Create the SSH key file and fill the known_hosts to avoid a prompt from ssh (1st time connecting to remote host)
- name: πŸ” Create Key File
run: |
mkdir ~/.ssh
touch ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: πŸ” Load Host Keys
run: |
echo "${{ secrets.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
- name: πŸ”‘ Populate Key
run: |
echo "${{ secrets.PRIVATE_SSH_KEY }}" > ~/.ssh/id_rsa
# Finally upload the build to the remote server location: the volume shared by the nginx container serving http requests
- name: πŸš€ Upload
run: |
rsync --archive --stats --verbose --delete ./build/blog/* ${{ secrets.CI_USER_NAME }}@iscsc.fr:${{ secrets.STATIC_WEBSITE_PATH}}

0 comments on commit cba404b

Please sign in to comment.