Update remote #54
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 and build static site | |
on: | |
push: | |
branches: [master] | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Set datetime env var | |
run: echo "DATETIME=$(date -u +"%Y%m%d-%H%M%SZ")" >> $GITHUB_ENV | |
- name: Set deploy folder env var | |
run: echo "TMP_FOLDER=/tmp/${{github.event.repository.name}}-${{env.DATETIME}}" >> $GITHUB_ENV | |
- name: Echo Node version | |
run: node -v | |
- name: Build Eleventy site | |
uses: extrawitz/11ty-dockerless-build@v1 | |
- name: Transfer built site to server | |
uses: appleboy/scp-action@master | |
with: | |
source: "dist" | |
target: "${{env.TMP_FOLDER}}" | |
strip_components: 1 | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
- name: Move built site to Nginx folder | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
find ${{ secrets.DEPLOY_FOLDER }} -mindepth 1 -delete | |
mv ${{env.TMP_FOLDER}}/* ${{ secrets.DEPLOY_FOLDER }} |