fix(netlify): use manual deploy
- https://docs.netlify.com/configure-builds/stop-or-activate-builds/
This commit is contained in:
parent
25b591301d
commit
ab57c90cec
|
@ -1,4 +1,4 @@
|
||||||
image: alpine:latest
|
image: node:lts-alpine
|
||||||
|
|
||||||
build_job:
|
build_job:
|
||||||
stage: build
|
stage: build
|
||||||
|
@ -45,10 +45,13 @@ netlify:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- apk update && apk add curl
|
- npm install
|
||||||
|
- npm install netlify-cli -g
|
||||||
|
- netlify --telemetry-disable
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- curl -X POST -d "{}" "https://api.netlify.com/build_hooks/$NETLIFY_BUILD_HOOK"
|
- npm run build
|
||||||
|
- netlify deploy --dir=public
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $NETLIFY == "true"'
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $NETLIFY == "true"'
|
||||||
|
|
48
src/build.js
48
src/build.js
|
@ -4,33 +4,43 @@
|
||||||
|
|
||||||
const { stream: gotStream } = require('got')
|
const { stream: gotStream } = require('got')
|
||||||
const unzip = require('extract-zip')
|
const unzip = require('extract-zip')
|
||||||
const { join } = require('path')
|
const { basename, join } = require('path')
|
||||||
const { mkdir, readdir, rm } = require('fs/promises')
|
const { mkdir } = require('fs/promises')
|
||||||
const { createWriteStream } = require('fs')
|
const { createWriteStream } = require('fs')
|
||||||
const { pipeline } = require('stream/promises')
|
const { pipeline } = require('stream/promises')
|
||||||
|
|
||||||
const rootPath = join(__dirname, '..')
|
const rootPath = join(__dirname, '..')
|
||||||
const tmpPath = join(rootPath, 'tmp')
|
const tmpPath = join(rootPath, 'tmp')
|
||||||
const zipPath = join(tmpPath, 'artifacts.zip')
|
const artifacts = {
|
||||||
const artifactsUrl = 'https://gitlab.com/curben/malware-filter/-/jobs/artifacts/main/download?job=pages'
|
'https://gitlab.com/curben/urlhaus-filter/-/jobs/artifacts/main/download?job=pages': 'urlhaus-filter.zip',
|
||||||
const publicPath = join(rootPath, 'public')
|
'https://gitlab.com/curben/phishing-filter/-/jobs/artifacts/main/download?job=pages': 'phishing-filter.zip',
|
||||||
|
'https://gitlab.com/curben/pup-filter/-/jobs/artifacts/main/download?job=pages': 'pup-filter.zip',
|
||||||
|
'https://gitlab.com/curben/tracking-filter/-/jobs/artifacts/main/download?job=pages': 'tracking-filter.zip'
|
||||||
|
}
|
||||||
|
|
||||||
|
const dl = async (link, filename) => {
|
||||||
|
const zipPath = join(tmpPath, filename)
|
||||||
|
console.log(`Downloading ${filename} from "${link}"`)
|
||||||
|
try {
|
||||||
|
await pipeline(
|
||||||
|
gotStream(link),
|
||||||
|
createWriteStream(zipPath)
|
||||||
|
)
|
||||||
|
} catch ({ message }) {
|
||||||
|
throw new Error(JSON.stringify({
|
||||||
|
error: message,
|
||||||
|
link,
|
||||||
|
filename
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Extracting ${basename(zipPath)}...`)
|
||||||
|
await unzip(zipPath, { dir: rootPath })
|
||||||
|
}
|
||||||
|
|
||||||
const f = async () => {
|
const f = async () => {
|
||||||
await mkdir(tmpPath, { recursive: true })
|
await mkdir(tmpPath, { recursive: true })
|
||||||
|
await Promise.all(Object.entries(artifacts).map(([link, filename]) => { return dl(link, filename) }))
|
||||||
console.log(`Downloading artifacts.zip from "${artifactsUrl}"`)
|
|
||||||
await pipeline(
|
|
||||||
gotStream(artifactsUrl),
|
|
||||||
createWriteStream(zipPath)
|
|
||||||
)
|
|
||||||
|
|
||||||
console.log('Extracting artifacts.zip...')
|
|
||||||
await unzip(zipPath, { dir: rootPath })
|
|
||||||
|
|
||||||
const files = await readdir(publicPath)
|
|
||||||
for (const file of files) {
|
|
||||||
if (file.startsWith('oisd')) await rm(join(publicPath, file))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
f()
|
f()
|
||||||
|
|
Loading…
Reference in New Issue