switch to use Fastly for deploying
This commit is contained in:
parent
cf37118113
commit
5999f383f9
32
.github/workflows/build.yml
vendored
32
.github/workflows/build.yml
vendored
@ -11,31 +11,31 @@ jobs:
|
|||||||
image: docker.io/rockylinux:9
|
image: docker.io/rockylinux:9
|
||||||
steps:
|
steps:
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: dnf -y upgrade && dnf -y install git python3 python3-pip cairo-devel
|
|
||||||
|
|
||||||
- name: setup ssh
|
|
||||||
env:
|
|
||||||
SSH_KEY: "${{ secrets.SSH_KEY }}"
|
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh/
|
dnf -y upgrade
|
||||||
echo "$SSH_KEY" > ~/.ssh/id_rsa
|
dnf -y install git python3 python3-pip cairo-devel
|
||||||
chmod 0700 ~/.ssh/
|
|
||||||
chmod 0600 ~/.ssh/id_rsa
|
|
||||||
|
|
||||||
- name: checkout
|
- name: checkout
|
||||||
env:
|
|
||||||
GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
|
||||||
run:
|
run:
|
||||||
git clone https://git.resf.org/$GITHUB_REPOSITORY.git $GITHUB_WORKSPACE
|
git clone https://git.resf.org/$GITHUB_REPOSITORY.git $GITHUB_WORKSPACE
|
||||||
|
|
||||||
- name: Install python requirements
|
- name: Install python requirements
|
||||||
run: python3 -m pip install -r requirements.txt
|
run: python3 -m pip install -r requirements.txt
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
python3 -m mkdocs build
|
||||||
|
|
||||||
|
- name: Install fastly CLI
|
||||||
|
run: |
|
||||||
|
dnf -y install \
|
||||||
|
npm \
|
||||||
|
https://github.com/fastly/cli/releases/download/v10.13.3/fastly_10.13.3_linux_amd64.rpm
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
env:
|
env:
|
||||||
GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
FASTLY_API_TOKEN: "${{ secrets.FASTLY_API_TOKEN }}"
|
||||||
GIT_AUTHOR_NAME: "Rocky Bot"
|
|
||||||
GIT_AUTHOR_EMAIL: "auto@rockylinux.org"
|
|
||||||
run: |
|
run: |
|
||||||
git remote set-url origin ssh://git@git.resf.org:22220/$GITHUB_REPOSITORY.git
|
pushd compute-js
|
||||||
python3 -m mkdocs gh-deploy --force
|
npm install
|
||||||
|
fastly compute publish
|
||||||
|
4
compute-js/.gitignore
vendored
Normal file
4
compute-js/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/node_modules
|
||||||
|
/bin
|
||||||
|
/pkg
|
||||||
|
/static-publisher
|
11
compute-js/fastly.toml
Normal file
11
compute-js/fastly.toml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# This file describes a Fastly Compute package. To learn more visit:
|
||||||
|
# https://www.fastly.com/documentation/reference/compute/fastly-toml
|
||||||
|
|
||||||
|
authors = ["FIXME@rocky.page"]
|
||||||
|
description = "FIXME"
|
||||||
|
language = "javascript"
|
||||||
|
manifest_version = 2
|
||||||
|
name = "FIXME.rocky.page"
|
||||||
|
|
||||||
|
[scripts]
|
||||||
|
build = "npm run build"
|
2051
compute-js/package-lock.json
generated
Normal file
2051
compute-js/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
compute-js/package.json
Normal file
23
compute-js/package.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "FIXME",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "FIXME",
|
||||||
|
"author": "FIXME",
|
||||||
|
"type": "module",
|
||||||
|
"devDependencies": {
|
||||||
|
"@fastly/compute-js-static-publish": "^6.0.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fastly/js-compute": "^3.20.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.0.0"
|
||||||
|
},
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"deploy": "fastly compute deploy",
|
||||||
|
"prebuild": "npx @fastly/compute-js-static-publish --build-static",
|
||||||
|
"build": "js-compute-runtime ./src/index.js ./bin/main.wasm"
|
||||||
|
}
|
||||||
|
}
|
18
compute-js/src/index.js
Normal file
18
compute-js/src/index.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/// <reference types="@fastly/js-compute" />
|
||||||
|
import { getServer } from '../static-publisher/statics.js';
|
||||||
|
const staticContentServer = getServer();
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-restricted-globals
|
||||||
|
addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
|
||||||
|
async function handleRequest(event) {
|
||||||
|
|
||||||
|
const response = await staticContentServer.serveRequest(event.request);
|
||||||
|
if (response != null) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do custom things here!
|
||||||
|
// Handle API requests, serve non-static responses, etc.
|
||||||
|
|
||||||
|
return new Response('Not found', { status: 404 });
|
||||||
|
}
|
34
compute-js/static-publish.rc.js
Normal file
34
compute-js/static-publish.rc.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright Fastly, Inc.
|
||||||
|
* Licensed under the MIT license. See LICENSE file for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Commented items are defaults, feel free to modify and experiment!
|
||||||
|
// See README for a detailed explanation of the configuration options.
|
||||||
|
|
||||||
|
/** @type {import('@fastly/compute-js-static-publish').StaticPublisherConfig} */
|
||||||
|
const config = {
|
||||||
|
rootDir: "../site",
|
||||||
|
staticContentRootDir: "./static-publisher",
|
||||||
|
// kvStoreName: false,
|
||||||
|
// excludeDirs: [ './node_modules' ],
|
||||||
|
// excludeDotFiles: true,
|
||||||
|
// includeWellKnown: true,
|
||||||
|
// contentAssetInclusionTest: (filename) => true,
|
||||||
|
// contentCompression: [ 'br', 'gzip' ], // For this config value, default is [] if kvStoreName is null.
|
||||||
|
// moduleAssetInclusionTest: (filename) => false,
|
||||||
|
// contentTypes: [
|
||||||
|
// { test: /.custom$/, contentType: 'application/x-custom', text: false },
|
||||||
|
// ],
|
||||||
|
server: {
|
||||||
|
publicDirPrefix: "",
|
||||||
|
staticItems: ["/assets/"],
|
||||||
|
// compression: [ 'br', 'gzip' ],
|
||||||
|
spaFile: false,
|
||||||
|
notFoundPageFile: "/404.html",
|
||||||
|
autoExt: [],
|
||||||
|
autoIndex: ["index.html","index.htm"],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
Loading…
Reference in New Issue
Block a user