Last active
May 27, 2020 16:43
-
-
Save trovster/ffdd927e3e9670cfbb7b2b10f2544191 to your computer and use it in GitHub Desktop.
Switching the baseUrl in Eleventy.js
This file contains 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
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 |
This file contains 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
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