Skip to content

Instantly share code, notes, and snippets.

@trovster
Last active May 27, 2020 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trovster/ffdd927e3e9670cfbb7b2b10f2544191 to your computer and use it in GitHub Desktop.
Save trovster/ffdd927e3e9670cfbb7b2b10f2544191 to your computer and use it in GitHub Desktop.
Switching the baseUrl in Eleventy.js
name: Build and Deploy
on:
push:
branches: [ master ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Install and Build 🔧
run: |
npm ci
npm test
npm run build -- --pathprefix=/repository-name/
env:
GITHUB_URL: https://username.github.io
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: dist
const site = {
baseUrl: '/',
}
module.exports = () => {
if (process.env.ELEVENTY_BASE_URL) {
site.baseUrl = process.env.ELEVENTY_BASE_URL
}
// https://docs.netlify.com/configure-builds/environment-variables/#deploy-urls-and-metadata
if (process.env.URL) {
site.baseUrl = process.env.URL
}
// https://vercel.com/docs/v2/build-step#system-environment-variables
if (process.env.VERCEL_URL) {
site.baseUrl = process.env.VERCEL_URL
}
// https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
if (process.env.GITHUB_URL) {
site.baseUrl = process.env.GITHUB_URL
}
return site
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment