diff --git a/.github/workflows/hugo.yml b/.github/workflows/hugo.yml new file mode 100644 index 0000000..9c25009 --- /dev/null +++ b/.github/workflows/hugo.yml @@ -0,0 +1,132 @@ +# Sample workflow for building and deploying a Hugo site to GitHub Pages +name: Deploy Hugo site to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: + - main + + # Runs on pull requests + 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 +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 + +# Default to bash +defaults: + run: + # GitHub-hosted runners automatically enable `set -eo pipefail` for Bash shells. + shell: bash + +jobs: + # Build job + build: + runs-on: ubuntu-latest + env: + HUGO_VERSION: 0.148.0 + HUGO_ENVIRONMENT: production + TZ: America/New_York + steps: + - name: Install Hugo CLI + 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 + run: sudo snap install dart-sass + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Setup Pages + id: pages + uses: actions/configure-pages@v5 + - name: Cache Restore + id: cache-restore + uses: actions/cache/restore@v4 + with: + path: | + ${{ runner.temp }}/hugo_cache + key: hugo-${{ github.run_id }} + restore-keys: + hugo- + - name: Configure Git + run: git config core.quotepath false + - name: Build with Hugo + run: | + hugo \ + --gc \ + --minify \ + --baseURL "${{ steps.pages.outputs.base_url }}/" \ + --cacheDir "${{ runner.temp }}/hugo_cache" + - name: Cache Save + id: cache-save + uses: actions/cache/save@v4 + with: + path: | + ${{ runner.temp }}/hugo_cache + key: ${{ steps.cache-restore.outputs.cache-primary-key }} + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./public + + # Deployment job + deploy: + if: github.ref == 'refs/heads/main' + 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@v4 + + # PR Preview job + preview: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + needs: build + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: github-pages + path: ./preview + - name: Extract site + run: | + cd preview + tar -xf artifact.tar + - name: Install surge + run: npm install -g surge + - name: Deploy to surge.sh + run: | + export SURGE_DOMAIN="thepotato-tech-pr-${{ github.event.number }}.surge.sh" + surge ./preview --domain $SURGE_DOMAIN --token ${{ secrets.SURGE_TOKEN }} + echo "Preview URL: https://$SURGE_DOMAIN" >> $GITHUB_STEP_SUMMARY + - name: Comment PR + uses: actions/github-script@v7 + with: + script: | + const domain = `thepotato-tech-pr-${{ github.event.number }}.surge.sh`; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `🚀 Preview deployed to: https://${domain}` + }); diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 643334d..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,13 +0,0 @@ -image: registry.gitlab.com/pages/hugo/hugo_extended:latest - -variables: - GIT_SUBMODULE_STRATEGY: recursive - -pages: - script: - - hugo - artifacts: - paths: - - public - only: - - main diff --git a/.woodpecker.yml b/.woodpecker.yml deleted file mode 100644 index e54f6b3..0000000 --- a/.woodpecker.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -branches: main - -variables: - surge_settings: &surge_settings - path: public - surge_token: - from_secret: SURGE_TOKEN - forge_type: gitea - forge_url: https://git.shrug.pw - forge_repo_token: - from_secret: SURGE_GITEA - -clone: - git: - image: woodpeckerci/plugin-git - settings: - recursive: true - -pipeline: - build: - image: registry.gitlab.com/pages/hugo/hugo_extended:latest - commands: - - hugo - - preview: - image: woodpeckerci/plugin-surge-preview - secrets: [SURGE_TOKEN, SURGE_GITEA] - settings: *surge_settings - when: - event: pull_request - - teardown-preview: - image: woodpeckerci/plugin-surge-preview - secrets: [SURGE_TOKEN, SURGE_GITEA] - settings: *surge_settings - environment: - - CI_BUILD_EVENT=pull_close - when: - event: pull_close - - publish: - image: git.shrug.pw/neil/containers/woodpecker-ci:latest - secrets: [ssh_key, GITLAB_DEPLOY_TOKEN] - environment: - - GIT_AUTHOR_NAME="Woody the Woodpecker" - - GIT_AUTHOR_EMAIL=ci@shrug.pw - commands: - - mkdir -p ~/.ssh/ - - echo "$SSH_KEY" > ~/.ssh/id_rsa - - chmod 0700 ~/.ssh/ - - chmod 0600 ~/.ssh/id_rsa - - bash deploy.sh - when: - branch: main - event: [push] -