Update GitHub Pages #234
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: Update GitHub Pages | |
on: | |
release: | |
types: [published] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Default to bash | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: '0.125.7' | |
extended: true | |
- name: Run tests | |
run: ./v4/tests/exampleSite/test-theme.sh | |
deploy: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: '0.125.7' | |
extended: true | |
- name: Create new demo site | |
run: | | |
hugo new site /tmp/demo-site | |
rm /tmp/demo-site/archetypes/default.md | |
- name: Init Hugo module | |
working-directory: /tmp/demo-site | |
run: | | |
hugo mod init github.com/Lednerb/bilberry-hugo-theme/exampleSite | |
hugo mod get -u | |
cat go.mod | |
- name: Copy exampleSite content to new site | |
run: cp -r ./v4/exampleSite/* /tmp/demo-site | |
- name: Adjust hugo.toml | |
working-directory: /tmp/demo-site | |
run: | | |
sed -i "s/baseURL = .*$/baseURL = \"https:\/\/lednerb.github.io\/bilberry-hugo-theme\/\"/" hugo.toml | |
cat hugo.toml | grep baseURL | |
version=$(grep -Po "(?<=v4\s)[^\s//]+" go.mod) | |
echo $version | |
sed -i "s/creditsText = .*$/creditsText = \"Bilberry Hugo Theme $version\"/" hugo.toml | |
cat hugo.toml | grep creditsText | |
sed -i "s/creditsUrl = .*$/creditsUrl = \"https:\/\/github.com\/Lednerb\/bilberry-hugo-theme\/tree\/$version\"/" hugo.toml | |
cat hugo.toml | grep creditsUrl | |
- name: Build | |
working-directory: /tmp/demo-site | |
run: | | |
rm -rf themes/bilberry-hugo-theme | |
hugo --environment development | |
> public/.nojekyll | |
sed -i "s~webfonts~bilberry-hugo-theme/webfonts~g" public/theme.css | |
sed -i "s~/fonts~/bilberry-hugo-theme/fonts~g" public/theme.css | |
- name: Deploy to GitHub Pages | |
if: success() | |
uses: crazy-max/ghaction-github-pages@v3 | |
with: | |
target_branch: gh-pages | |
build_dir: ../../../../../../../../tmp/demo-site/public | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |