Skip to content

Commit

Permalink
Adding base_url parameter to Github Actions config
Browse files Browse the repository at this point in the history
The main usage of this actions is serving Jekyll sites from GH Pages. As in majority of cases this sites get served from sub domain (by repo name) it would useful to be able to set base_url for this sites. Sure it's probably can be done with different configs (_config_production.yml etc) but having this option makes it easier.
  • Loading branch information
Rukomoynikov committed Dec 1, 2024
1 parent c2d3f38 commit 0f2997b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ steps:
|-------|---------|-------------|
| `source` | `./` | The directory to build from |
| `destination` | `./_site` | The directory to write output into<br>(this should match the `path` input of the [`actions/upload-pages-artifact`](https://github.com/actions/upload-pages-artifact) action) |
| `base_url` | `` | Name of sub-directory the site is served from e.g., /my-repo-name. |
| `future` | `false` | If `true`, writes content dated in the future |
| `build_revision` | `$GITHUB_SHA` | The SHA-1 of the Git commit for which the build is running |
| `verbose` | `false` | If `true`, prints verbose output in logs |
Expand Down
26 changes: 15 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
name: 'Build Jekyll for GitHub Pages'
description: 'A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages'
author: 'GitHub'
name: "Build Jekyll for GitHub Pages"
description: "A simple GitHub Action for producing Jekyll build artifacts compatible with GitHub Pages"
author: "GitHub"
inputs:
source:
description: 'Directory where the source files reside.'
description: "Directory where the source files reside."
required: false
default: ./
destination:
description: 'Output directory of the build. Although it can be nested inside the source, it cannot be the same as the source directory.'
description: "Output directory of the build. Although it can be nested inside the source, it cannot be the same as the source directory."
required: false
default: ./_site
future:
description: 'Publishes posts with a future date. When set to true, the build is made with the --future option which overrides the future option that may be set in a Jekyll configuration file.'
description: "Publishes posts with a future date. When set to true, the build is made with the --future option which overrides the future option that may be set in a Jekyll configuration file."
required: false
default: false
build_revision:
description: 'The SHA-1 of the git commit for which the build is running. Default to GITHUB_SHA.'
description: "The SHA-1 of the git commit for which the build is running. Default to GITHUB_SHA."
required: false
default: ${{ github.sha }}
base_url:
description: "Name of sub-directory the site is served from e.g., /my-repo-name."
required: false
default: ""
verbose:
description: 'Verbose output'
description: "Verbose output"
required: false
default: true
token:
description: 'GitHub token'
description: "GitHub token"
required: true
default: ${{ github.token }}
runs:
using: 'docker'
image: 'docker://ghcr.io/actions/jekyll-build-pages:v1.0.13'
using: "docker"
image: "docker://ghcr.io/actions/jekyll-build-pages:v1.0.13"
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fi
{ cd "$PAGES_GEM_HOME" || { echo "::error::pages gem not found"; exit 1; }; }

# Run the command, capturing the output
build_output="$($GITHUB_PAGES_BIN build "$VERBOSE" "$FUTURE" --source "$SOURCE_DIRECTORY" --destination "$DESTINATION_DIRECTORY")"
build_output="$($GITHUB_PAGES_BIN build "$VERBOSE" "$FUTURE" --source "$SOURCE_DIRECTORY" --baseurl "$BASE_DIRECTORY" --destination "$DESTINATION_DIRECTORY")"

# Capture the exit code
exit_code=$?
Expand Down

0 comments on commit 0f2997b

Please sign in to comment.