diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml index 6874b29..2a672f0 100644 --- a/.github/workflows/hugo.yml +++ b/.github/workflows/hugo.yml @@ -1,4 +1,5 @@ -# Sample workflow for building and deploying a Hugo site to GitHub Pages +# Build the Hugo site and publish it to the `gh-pages` branch, which is the +# configured GitHub Pages source for this repository. name: Deploy Hugo site to Pages on: @@ -6,14 +7,15 @@ on: push: branches: ["main"] + # Build-only validation on pull requests (no deploy) + pull_request: + # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +# The GITHUB_TOKEN needs write access to push the built site to `gh-pages` permissions: - contents: read - pages: write - id-token: write + contents: write # Allow one concurrent deployment concurrency: @@ -26,7 +28,6 @@ defaults: shell: bash jobs: - # Build job build: runs-on: ubuntu-latest env: @@ -36,15 +37,10 @@ jobs: run: | wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ && sudo dpkg -i ${{ runner.temp }}/hugo.deb - - name: Install Dart Sass Embedded - run: sudo snap install dart-sass-embedded - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive - - name: Setup Pages - id: pages - uses: actions/configure-pages@v3 - name: Install Node.js dependencies run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" - name: Build with Hugo @@ -54,21 +50,18 @@ jobs: HUGO_ENV: production run: | hugo \ + --gc \ --minify \ - --baseURL "${{ steps.pages.outputs.base_url }}/" - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 - with: - path: ./public - - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 + --baseURL "https://animeeffectsdevs.github.io/" + - name: Publish to gh-pages + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd public + git init --initial-branch=gh-pages + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add -A + git commit --message "Deploy ${GITHUB_SHA:0:7}" + git push --force "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages diff --git a/assets/js/custom.js b/assets/js/custom.js new file mode 100644 index 0000000..0b0609f --- /dev/null +++ b/assets/js/custom.js @@ -0,0 +1,13 @@ +// The theme's bundled updateDate() has a long-standing bug: it assigns +// `year.innerHTML` (the number) instead of `yearEl.innerHTML`, so the footer +// copyright year is never refreshed client-side. This overrides the theme's +// `assets/js/custom.js`, which is concatenated last into js/bundle.js. +// +// Keep the copyright year current even when the site was built in an earlier +// year (stale cache, missed deploys). +(function updateCopyrightYear() { + var yearEl = document.querySelector('footer .year'); + if (yearEl) { + yearEl.textContent = String(new Date().getFullYear()); + } +})(); diff --git a/config/_default/params.toml b/config/_default/params.toml index a898ca8..b6d0a32 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -34,5 +34,5 @@ centerLogo = true # optional # attribution. Feel free to delete this [author] - name = "AnimeEffectDevs" + name = "AnimeEffectsDevs" url = "https://github.com/AnimeEffectsDevs?type=source"