Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #14

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

WIP #14

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/.yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
extends: default

rules:
document-start:
present: false
line-length: disable
truthy:
check-keys: false
7 changes: 3 additions & 4 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
strategy:
matrix:
action-name: ${{fromJson(needs.prepare.outputs.container_names_json)}}
docker-platform: [linux/amd64, linux/arm64]

env:
REGISTRY: ghcr.io
Expand Down Expand Up @@ -90,8 +89,8 @@ jobs:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.docker-platform }}
provenance: false # Bug: https://github.com/docker/build-push-action/issues/820
platforms: linux/amd64,linux/arm64
# Disable "provenance" vecause of this bug: https://github.com/docker/build-push-action/issues/820
provenance: false
cache-from: type=gha
cache-to: type=gha,mode=max

17 changes: 12 additions & 5 deletions .github/workflows/jekyll-feed-to-vespa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
required: false
default: 'info'
type: string
hook-post-build-script:
description: |
Script to run after Jekyll build, can be multi-line.
Ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsrun
required: false
type: string

defaults:
run:
Expand All @@ -17,17 +23,18 @@ defaults:
shell: bash

jobs:
lint:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Build with Jekyll
uses: vespa-engine/gh-actions/jekyll-build-json@main
uses: vespa-engine/gh-actions/jekyll-build-json@fix-jekyll-build
with:
log_level: ${{ github.event.inputs.log_level }}
log_level: ${{ inputs.log_level }}

- name: List JSON
- name: Hook - Post-build
if: ${{ inputs.hook-post-build-script != '' }}
run: |
find _site -type f -name '*.json'
${{ inputs.hook-post-build-script }}
12 changes: 1 addition & 11 deletions jekyll-build-json/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,4 @@
source "https://rubygems.org"

# Manage our dependency on the version of the github-pages gem here.
gem "github-pages", "= 232"

# Explicitly include this gem here.
# It is not directly included in the github-pages gem list of dependencies,
# even though it is included in the original GitHub Pages build infrastructure.
gem "jekyll-include-cache", "= 0.2.1"
gem "jekyll-octicons", "~> 14.2"
gem "minima", "~> 2.0"

# Work-around for webrick no longer included in Ruby 3.0 (https://github.com/jekyll/jekyll/issues/8523)
gem "webrick"
gem 'github-pages', group: :jekyll_plugins
4 changes: 2 additions & 2 deletions jekyll-build-json/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ inputs:
default: ./_config.yml
log_level:
description: 'Log level for Jekyll build.'
required: false
required: true
default: 'info'
token:
description: 'GitHub token'
required: true
default: ${{ github.token }}
runs:
using: 'docker'
image: 'docker://ghcr.io/vespa-engine/gh-actions/jekyll-build-json'
image: 'docker://ghcr.io/vespa-engine/gh-actions/jekyll-build-json:pr-14'
2 changes: 1 addition & 1 deletion jekyll-build-json/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ JEKYLL_ARGS=("-p" "/opt/jekyll/plugins")
export JEKYLL_ENV="production"
export JEKYLL_GITHUB_TOKEN="${INPUT_TOKEN}"
export JEKYLL_BUILD_REVISION="${GITHUB_SHA}"
export JEKYLL_LOG_LEVEL="${INPUT_LOG_LEVEL}"
export JEKYLL_LOG_LEVEL="${INPUT_LOG_LEVEL:-info}"

if [[ "${JEKYLL_LOG_LEVEL}" = "verbose" || "${JEKYLL_LOG_LEVEL}" = "debug" ]]; then
JEKYLL_ARGS+=("-V")
Expand Down
25 changes: 13 additions & 12 deletions jekyll-build-json/vespa_index_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

module Jekyll

class JSONFile < Page; end

class VespaIndexGenerator < Jekyll::Generator
priority :lowest
safe true

def generate(site)
@site = site
puts "::debug::VespaIndexGenerator"
puts "site.config: #{(site.config).inspect}"
puts "::debug::VespaIndexGenerator"

raise "Wrong parameter type, expected Jekyll::Site, got #{site.class}" unless site.is_a?(Jekyll::Site)
raise "Search configuration not found" unless site.config.key?("search")
Expand All @@ -38,7 +38,7 @@ def generate(site)
url = page.url
url += 'index.html' if url[-1, 1] == '/'

text = extract_text(page)
text = extract_text(page.to_liquid)
outlinks = extract_links(page)
headers = extract_headers(page)
keywords = get_keywords(page)
Expand All @@ -61,14 +61,15 @@ def generate(site)
})
end
json = JSON.pretty_generate(operations)
# puts "::debug::Writing index file: #{namespace}_index.json"
# File.open(__dir__ + namespace + "_index.json", "w") { |f| f.write(json) }

puts "::debug::Writing index file: #{namespace}_index.json"
index_file = PageWithoutAFile.new(@site, __dir__, "", namespace + "_index.json")
index_file.content = json
index_file.data["layout"] = nil
index_file
json_dest = "json_indexes/"
full_path = "#{site.dest}/#{json_dest}"
FileUtils.mkdir_p(full_path) # Ensure the directory exists

fname = "#{namespace}_index.json"
puts "::debug::Writing JSON file for \"#{namespace}\" namespace to: #{full_path}#{fname}"
File.open("#{full_path}#{fname}", 'w') { |f| f.write(json) }

site.pages << Jekyll::JSONFile.new(site, site.dest, json_dest, fname)
end

def should_skip?(search_config, page)
Expand Down
Loading