Deploy Jekyll site in production #240
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# Bring jekyll Page into production | |
name: Deploy Jekyll site in production | |
on: | |
# Runs on pushes (and merges) targeting the main branch | |
push: | |
branches: ["main"] | |
# Runs regularly | |
# for requirements regarding schedule see also | |
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule | |
# Notes: | |
# - The schedule event can be delayed during periods of high loads of GitHub Actions | |
# workflow runs. High load times include the start of every hour. If the load is | |
# sufficiently high enough, some queued jobs may be dropped. To decrease the chance | |
# of delay, schedule your workflow to run at a different time of the hour. | |
# - This event will only trigger a workflow run if the workflow file is on the default branch branch. | |
# - Scheduled workflows will only run on the default branch. | |
# - In a public repository, scheduled workflows are automatically disabled when no repository activity has occurred in 60 days. | |
# | |
# UTC does not have winter-/summer time | |
schedule: | |
- cron: '47 9 * * *' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Set permissions | |
permissions: | |
contents: read | |
id-token: write # TODO: required? | |
# 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-to-prod" | |
cancel-in-progress: false | |
jobs: | |
# Build job | |
build: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Setup Ruby | |
uses: ruby/[email protected] | |
with: | |
ruby-version: '3.3' # Not needed with a .ruby-version file | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
cache-version: 0 # Increment this number if you need to re-download cached gems | |
working-directory: "source/" | |
# w/o --future, w/o --basepath | |
# see also _config.yml (url) | |
- name: Build with Jekyll | |
run: cd "source"; ls -l; bundle exec jekyll build | |
env: | |
JEKYLL_ENV: production | |
- name: 'Upload Artifact' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: jekyll-production-site | |
path: 'source/_site/' | |
# Deployment job on production site | |
# see also https://github.com/marketplace/actions/lftp-mirror-action | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: build | |
environment: production # This is mandatory for accessing secrets | |
steps: | |
- name: Download a single artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: jekyll-production-site | |
- shell: bash | |
run: | | |
pwd | |
ls -l | |
tree -f | |
- name: view the secrets context | |
shell: bash | |
run: echo "$SECRETS_CONTEXT" | |
env: | |
SECRETS_CONTEXT: ${{ toJson(secrets) }} | |
- name: Deploy files via SFTP | |
uses: pressidium/lftp-mirror-action@v1 | |
with: | |
# SFTP credentials | |
host: ${{ secrets.SFTP_HOST }} | |
port: ${{ secrets.SFTP_PORT }} | |
user: ${{ secrets.SFTP_USER }} | |
pass: ${{ secrets.SFTP_PASS }} | |
# lftp settings | |
onlyNewer: true | |
settings: 'sftp:auto-confirm=yes' | |
# Mirror command options | |
localDir: '.' | |
remoteDir: '/customers/9/b/4/nobutthefrog.com/httpd.www' | |
reverse: true | |
ignoreFile: '.lftp_ignore' | |
options: '--verbose --delete' |