Last active
November 23, 2023 15:35
-
-
Save veerendra2/28d35b44c8340d5a801e5606edb32f45 to your computer and use it in GitHub Desktop.
Hugo Site Github Actions Workflow
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: 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/zhujunsan/a0becf82ade50ed06115