Add Content #35
This file contains hidden or 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
| # .github/workflows/deploy-hugo.yml | |
| name: Build and Deploy Hugo Site with External Content | |
| on: | |
| push: | |
| branches: | |
| - main # Trigger on push to the main branch of your Hugo site repo | |
| repository_dispatch: # Allows triggering from other repositories | |
| types: [content-updated] # Custom event type to listen for | |
| workflow_dispatch: # Allows manual trigger from GitHub Actions tab | |
| jobs: | |
| build_and_deploy: | |
| runs-on: ubuntu-latest # Or macos-latest, windows-latest | |
| permissions: # <--- ADD THIS BLOCK | |
| contents: write # This grants write access to the repository contents | |
| pages: write # Grants permission to deploy to GitHub Pages (if configured) | |
| id-token: write # Required for OIDC, good practice | |
| steps: | |
| - name: Checkout Hugo Site Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # If your Hugo site repo itself has submodules (e.g., for themes), enable this | |
| submodules: true | |
| - name: Clone External Content Repository | |
| # This step clones your content repo into the designated content path | |
| # IMPORTANT: Replace 'your-github-username' and 'my-hugo-content' | |
| # You might need a Personal Access Token (PAT) if the content repo is private | |
| # or if you're hitting rate limits for unauthenticated clones. | |
| run: | | |
| echo "Cloning content into content/posts..." | |
| git clone https://github.com/pinnotes/notes.git content/posts | |
| # env: | |
| # If 'my-hugo-content' is private, create a PAT with 'repo' scope | |
| # and add it as a repository secret named 'CONTENT_REPO_PAT' | |
| # GH_TOKEN: ${{ secrets.CONTENT_REPO_PAT }} # Uncomment if content repo is private | |
| - name: Setup Hugo | |
| uses: peaceiris/actions-hugo@v3 | |
| with: | |
| hugo-version: 'latest' # Or a specific version like '0.127.0' | |
| extended: true # Essential for SASS/SCSS and some advanced features | |
| - name: Build Hugo Site | |
| # Add any custom build flags, e.g., baseURL if deploying to a subdirectory | |
| run: hugo --minify --baseURL "/" # Adjust baseURL if needed for your hosting | |
| - name: Deploy to GitHub Pages (Example) | |
| # This step assumes you want to deploy to GitHub Pages | |
| # The 'public' directory will be pushed to the 'gh-pages' branch of THIS repo. | |
| uses: peaceiris/actions-gh-pages@v4 | |
| if: github.ref == 'refs/heads/main' # Only deploy from main branch pushes | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub Actions | |
| publish_dir: ./public # Directory containing your built Hugo site | |
| # This will create/update the 'gh-pages' branch for your site. | |
| # If your repo is `user/user.github.io`, it deploys to main branch. | |
| # cname: example.com # Uncomment and set if using a custom domain |