Merge pull request #11 from leicesterhackspace/develop #5
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 to production | |
on: | |
push: | |
branches: | |
- master | |
permissions: | |
contents: read | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "deploy" | |
cancel-in-progress: false | |
jobs: | |
build: # Build the website | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
lfs: 'true' | |
submodules: true # Fetch Hugo themes (true OR recursive) | |
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | |
- name: Install Dart Sass | |
run: sudo snap install dart-sass | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v3 | |
with: | |
hugo-version: '0.119.0' | |
extended: true | |
- name: Build | |
run: hugo -D --baseURL "https://leicesterhackspace.org.uk/" | |
deploy: # Handle the connection to the production server | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: SSH and prepare staging folder | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.PLESK_SSH_HOST }} | |
username: ${{ secrets.PLESK_SSH_USER }} | |
key: ${{ secrets.PLESK_SSH_KEY }} | |
script: | | |
"/bin/mkdir staging" | |
"/bin/ln -l htacess staging/.htaccess" | |
- name: SCP files across | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.PLESK_SSH_HOST }} | |
username: ${{ secrets.PLESK_SSH_USER }} | |
key: ${{ secrets.PLESK_SSH_KEY }} | |
source: "public/*" | |
target: "/staging" | |
- name: SSH and make new version live | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.PLESK_SSH_HOST }} | |
username: ${{ secrets.PLESK_SSH_USER }} | |
key: ${{ secrets.PLESK_SSH_KEY }} | |
script: | | |
"/bin/mv production to-be-removed" | |
"/bin/mv staging production" | |
"/bin/rm -rf to-be-removed" |