Reputation: 6586
Can someone point me to the instructions for setting up a custom deploy for GitHub pages? (My Google skills are failing me.)
I have a site that needs only one modification when I deploy it on GitHub Pages: I want to replace all occurrences of foo.com
with bar.com
. I know that the first two steps are
At this point, do I need to do anything else? Will adding my own, custom .github directory shadow/overwrite any necessary actions for deploying the web site?
(For those who are curious: I know that I can write a simple Jekyll plug-in to do this; but, I'd rather not add the Jekyl front matter to my files. Plus, Jekyll seems like overkill for the one, simple transformation I need.)
Upvotes: 3
Views: 2156
Reputation: 6586
This is the workflow I created based on @VonC's suggestion:
The only difference between the example below and GitHub's static.yml
is that I inserted lines 33-38 (the addition of the search-and-replace step using jacobtomlinson/gha-find-replace@v2
).
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# 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 one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Replace URL
uses: jacobtomlinson/gha-find-replace@v2
with:
find: "http://localhost:8000"
replace: "https://myPage.github.io"
regex: false
- name: Setup Pages
uses: actions/configure-pages@v1
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@main
Upvotes: 1
Reputation: 1324023
Considering JamesIves/github-pages-deploy-action
can be configured to push your production-ready code into any branch you'd like, an alternative would be for your action to:
steps: - name: Replace
which would replace the text in what was checked outFor the first point, you can use for instance a find-and-replace
action, to find foo.com
and replace it with bar.com
.
Note: since you are using a GitHub Action, you can specify said action as publishing source
You can now deploy to a GitHub Pages site directly from a repository using GitHub Actions, without needing to set up a publishing source.
Using Actions to orchestrate Pages publishing provides many more options for choosing your authoring framework (Next.js, Hugo, Gatsby, Jekyll, NuxtJS or other technologies, and the associated versions thereof) as well as giving you finer control over the publishing process, such as leveraging deployment gates.
We have written several starter workflows for the most common frameworks but also have a “Static“ option if you want to deploy the contents of your repository with no build step.
static.yml
one to include your change)Upvotes: 1