From f2fdf3594f64ae8dc6110a8010977141660262b0 Mon Sep 17 00:00:00 2001 From: Marlon Saglia Date: Tue, 3 Sep 2024 11:05:40 +0200 Subject: [PATCH] WIP --- .github/workflows/.yamllint | 2 ++ .github/workflows/docker-publish.yml | 7 +++---- .github/workflows/jekyll-feed-to-vespa.yml | 17 ++++++++++++----- jekyll-build-json/Gemfile | 12 +----------- jekyll-build-json/action.yml | 4 ++-- jekyll-build-json/entrypoint.sh | 2 +- jekyll-build-json/vespa_index_generator.rb | 19 ++++++++----------- 7 files changed, 29 insertions(+), 34 deletions(-) diff --git a/.github/workflows/.yamllint b/.github/workflows/.yamllint index f28a9f8..b7f66a1 100644 --- a/.github/workflows/.yamllint +++ b/.github/workflows/.yamllint @@ -2,6 +2,8 @@ extends: default rules: + document-start: + present: false line-length: disable truthy: check-keys: false diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 32a05e4..22b5c55 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -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 @@ -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 - diff --git a/.github/workflows/jekyll-feed-to-vespa.yml b/.github/workflows/jekyll-feed-to-vespa.yml index 0b179a1..50fbaca 100644 --- a/.github/workflows/jekyll-feed-to-vespa.yml +++ b/.github/workflows/jekyll-feed-to-vespa.yml @@ -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: @@ -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 }} diff --git a/jekyll-build-json/Gemfile b/jekyll-build-json/Gemfile index 26e7462..c2152ed 100644 --- a/jekyll-build-json/Gemfile +++ b/jekyll-build-json/Gemfile @@ -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 diff --git a/jekyll-build-json/action.yml b/jekyll-build-json/action.yml index 51b0d65..3d4095f 100644 --- a/jekyll-build-json/action.yml +++ b/jekyll-build-json/action.yml @@ -16,7 +16,7 @@ inputs: default: ./_config.yml log_level: description: 'Log level for Jekyll build.' - required: false + required: true default: 'info' token: description: 'GitHub token' @@ -24,4 +24,4 @@ inputs: 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' diff --git a/jekyll-build-json/entrypoint.sh b/jekyll-build-json/entrypoint.sh index 6de16a5..21aefa4 100755 --- a/jekyll-build-json/entrypoint.sh +++ b/jekyll-build-json/entrypoint.sh @@ -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") diff --git a/jekyll-build-json/vespa_index_generator.rb b/jekyll-build-json/vespa_index_generator.rb index ba56850..4a0b23d 100644 --- a/jekyll-build-json/vespa_index_generator.rb +++ b/jekyll-build-json/vespa_index_generator.rb @@ -11,9 +11,7 @@ class VespaIndexGenerator < Jekyll::Generator 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") @@ -61,14 +59,13 @@ 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 = "#{__dir__}/#{json_dest}" + FileUtils.mkdir_p(full_path) # Ensure the directory exists + + fname = "#{full_path}#{namespace}_index.json" + puts "::debug::Writing JSON file for '#{namespace}' namespace to: #{fname}" + File.open(fname, 'w') { |f| f.write(json) } end def should_skip?(search_config, page)