generated from hugo-fixit/hugo-fixit-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
79 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,24 @@ | ||
name: Hugo build and deploy | ||
name: Deploy with Hugo | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- '.github/workflows/deploy.yml' | ||
- 'assets/**' | ||
- 'config/**' | ||
- 'content/**' | ||
- 'data/**' | ||
- 'static/**' | ||
- 'themes/**' | ||
- 'go.mod' | ||
- 'go.sum' | ||
workflow_run: | ||
workflows: ['Update theme'] | ||
types: | ||
- completed | ||
workflow_dispatch: | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
# 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 | ||
|
||
branches: | ||
- main | ||
|
||
jobs: | ||
# Build job | ||
build: | ||
build-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Cache Hugo resources | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-hugo-resources | ||
with: | ||
path: resources | ||
key: ${{ env.cache-name }} | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.17.0" | ||
- run: go version | ||
- name: Cache Go Modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Setup Hugo | ||
uses: peaceiris/actions-hugo@v3 | ||
with: | ||
# use the environment variable HUGO_VERSION as the hugo version, if not set, use `latest`. | ||
hugo-version: ${{ vars.HUGO_VERSION || 'latest' }} | ||
extended: true | ||
- name: Hugo build | ||
run: hugo --gc --minify --logLevel info | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
# Upload only the public directory | ||
path: './public' | ||
|
||
# Deployment job | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
- uses: actions/checkout@v2 | ||
- name: Setup Hugo | ||
uses: peaceiris/actions-hugo@v2 | ||
with: | ||
hugo_version: ${{ vars.HUGO_VERSION || 'latest' }} | ||
extended: true | ||
- name: Build Site | ||
run: hugo | ||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.TOKEN }} | ||
publish_dir: ./public |