deploy-to-github-pages #579
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-github-pages | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_run: | |
workflows: ["create-post"] | |
types: [completed] | |
branches: [main] | |
workflow_dispatch: | |
# 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: "pages" | |
cancel-in-progress: false | |
# Default to bash | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# see: https://github.com/actions/checkout | |
with: | |
submodules: recursive | |
fetch-depth: 1 | |
- name: Cache Hugo resources | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-hugo-resources | |
with: | |
path: resources | |
key: ${{ env.cache-name }} | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: "latest" | |
extended: true | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v3 | |
- name: Build Github Pages | |
env: | |
# For maximum backward compatibility with Hugo modules | |
HUGO_ENVIRONMENT: production | |
HUGO_ENV: production | |
run: hugo --minify --gc --baseURL "${{ steps.pages.outputs.base_url }}/" | |
- name: Upload Github Pages Artifact | |
uses: actions/[email protected] | |
with: | |
path: ./public | |
# Deployment to github pages | |
deploy-to-github-pages: | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
pages: write | |
id-token: write | |
actions: read | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
# see: https://github.com/actions/deploy-pages/ | |
uses: actions/[email protected] | |
with: | |
artifact_name: github-pages | |
# # Deploy to production | |
# deploy-to-production: | |
# runs-on: ubuntu-latest | |
# needs: build | |
# environment: | |
# name: production | |
# url: https://osguider.com/blog/ | |
# steps: | |
# - name: Download Artifact | |
# # see: https://github.com/actions/download-artifact | |
# uses: actions/[email protected] | |
# with: | |
# name: github-pages | |
# path: ./public | |
# - name: unArchive Artifact | |
# run: | | |
# ls -la --recursive | |
# - name: Deploy to Production | |
# id: projection | |
# # @see: https://github.com/easingthemes/ssh-deploy | |
# uses: easingthemes/[email protected] | |
# with: | |
# ARGS: "-rlgoDzvc -i --delete" | |
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
# SOURCE: "./public/*" | |
# REMOTE_HOST: ${{ secrets.SSH_REMOTE_HOST }} | |
# REMOTE_PORT: ${{ secrets.SSH_REMOTE_PORT }} | |
# REMOTE_USER: ${{ secrets.SSH_REMOTE_USER }} | |
# TARGET: ${{ secrets.SSH_REMOTE_TARGET }} | |
# SCRIPT_AFTER: cd "${{ secrets.SSH_REMOTE_TARGET }}" && ls -la && tar xf artifact.tar -C public/ |