Merge pull request #17 from leicesterhackspace/develop #10
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/" | |
- name: Upload built website as an Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: website | |
path: public/**/* | |
deploy: # Handle the connection to the production server | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download built `website` Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: website | |
path: staging | |
- 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: "staging/*,staging/**/*" | |
target: /var/www/vhosts/leicesterhackspace.org.uk | |
- 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: | | |
ln -s htacess staging/.htaccess | |
mv production to-be-removed | |
mv staging production | |
rm -rf to-be-removed |