diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index d4828ba..997a2d0 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -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' }} @@ -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}}