Skip to content

Instantly share code, notes, and snippets.

@veerendra2
Last active November 23, 2023 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veerendra2/28d35b44c8340d5a801e5606edb32f45 to your computer and use it in GitHub Desktop.
Save veerendra2/28d35b44c8340d5a801e5606edb32f45 to your computer and use it in GitHub Desktop.
Hugo Site Github Actions Workflow
name: Publish Hugo Site
on:
workflow_dispatch:
inputs:
blog:
description: "Publish Blog"
required: true
default: "yes"
pull_request:
types:
- closed
env:
SRC_REPO: "my-blog-source-content"
DEST_REPO: "veerendra2.github.io"
jobs:
build_publish:
runs-on: ubuntu-latest
steps:
- name: Checkout ${{ github.repository_owner }}/${{ env.SRC_REPO }}
uses: actions/checkout@v3
with:
path: ${{ env.SRC_REPO }}
- name: Checkout ${{ github.repository_owner }}/${{ env.DEST_REPO }}
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: ${{ github.repository_owner }}/${{ env.DEST_REPO }}
path: ${{ env.DEST_REPO }}
token: ${{ secrets.TOKEN_TO_PUSH_REPO }}
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "0.110.0"
extended: true
- name: Build Hugo site
run: |
hugo --minify \
-s ${{ github.workspace }}/${{ env.SRC_REPO }} \
-d ${{ github.workspace }}/${{ env.DEST_REPO }}
- name: Commit ${{ github.repository_owner }}/${{ env.DEST_REPO }}
run: |
cd ${{ github.workspace }}/${{ env.DEST_REPO }}
git config --global --add safe.directory ${{ github.workspace }}
git config --local user.email "actions@github.com"
git config --local user.name "GitHub actions"
git add -A
git commit -m "New changes" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.TOKEN_TO_PUSH_REPO }}
directory: ${{ github.workspace }}/${{ env.DEST_REPO }}
repository: ${{ github.repository_owner }}/${{ env.DEST_REPO }}
force: true
@veerendra2
Copy link
Author

veerendra2 commented Sep 24, 2022

@veerendra2
Copy link
Author

veerendra2 commented Oct 14, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment