# frozen_string_literal: true class BuildOceanicDocsJob < ApplicationJob queue_as :low_priority GITHUB_REPO = "https://github.com/OceanicJS/Oceanic" def perform(_type, payload) name = payload[:ref].split("/").slice(2..).join("/") return if name.start_with?("dependabot") Dir.mktmpdir(["oceanic-github-", name]) do |dir| Dir.chdir(dir) do system("git clone #{GITHUB_REPO} .", exception: true) system("git fetch -u origin #{name}:#{name}", exception: true) system("git checkout #{name}", exception: true) FileUtils.rm("#{dir}/.npmrc") system("npx pnpm install --ignore-scripts --frozen-lockfile", exception: true) system("npx pnpm run test:docs", exception: true) FileUtils.cp_r("#{dir}/docs", "/data/oceanic-docs/#{name}") Cache.redis.sadd("oceanic:versions", name) end end end end