2024-05-03 03:04:43 +00:00
|
|
|
# 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)
|
2024-05-04 04:35:08 +00:00
|
|
|
FileUtils.rm_rf("/data/oceanic-docs/#{name}")
|
2024-05-03 03:04:43 +00:00
|
|
|
FileUtils.cp_r("#{dir}/docs", "/data/oceanic-docs/#{name}")
|
|
|
|
Cache.redis.sadd("oceanic:versions", name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|