1.0 API + Autobuild
This commit is contained in:
parent
af5e5bd8f5
commit
cf4e34bbaa
5 changed files with 56 additions and 10 deletions
52
.github/workflows/main.yml
vendored
Normal file
52
.github/workflows/main.yml
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
name: Docker Build and Push with Version
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
DOCKER_REGISTRY: r.regnault.dev
|
||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||
PORTAINER_API_WEBHOOK: ${{ secrets.PORTAINER_API_WEBHOOK }}
|
||||
|
||||
jobs:
|
||||
build_and_push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ env.DOCKER_REGISTRY }}
|
||||
username: ${{ env.DOCKER_USERNAME }}
|
||||
password: ${{ env.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Semver
|
||||
run:
|
||||
echo "VERSION=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.DOCKER_REGISTRY }}/drunk-venti-api:latest
|
||||
${{ env.DOCKER_REGISTRY }}/drunk-venti-api:${{ env.VERSION }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
- name: Deploy to production
|
||||
uses: fjogeleit/http-request-action@v1.14.1
|
||||
with:
|
||||
url: ${{ format('{0}?API_TAG={1}',env.PORTAINER_API_WEBHOOK, env.VERSION) }}
|
||||
method: 'POST'
|
||||
preventFailureOnNoResponse: true
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"private": true,
|
||||
"version": "1.0",
|
||||
"scripts": {
|
||||
"dev": "next",
|
||||
"build": "next build",
|
||||
|
@ -11,6 +12,7 @@
|
|||
"swr": "^1.0.1",
|
||||
"redis": "^4.5.1",
|
||||
"dotenv": "^10.0.0",
|
||||
"fast-levenshtein": "^3.0.0"
|
||||
"fast-levenshtein": "^3.0.0",
|
||||
"lodash": "^4.17.21"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ import {getArtifacts} from "./utils";
|
|||
import {addResultToRedis, getResultFromRedis} from "../../../utils/redis";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
let t0 = performance.now()
|
||||
|
||||
let artifacts = JSON.parse(await getResultFromRedis(`artifact-all`))
|
||||
if (!artifacts) {
|
||||
|
@ -15,7 +14,4 @@ export default async function handler(req, res) {
|
|||
} else {
|
||||
res.status(404).json({message: "An error has occurred"})
|
||||
}
|
||||
|
||||
let t1 = performance.now();
|
||||
console.debug(`Execution took ${t1-t0} ms`)
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
import {getEvents} from "./utils";
|
||||
import {flatten} from "next/dist/shared/lib/flatten";
|
||||
import {flatten} from "lodash";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const events = await getEvents();
|
||||
if (events) {
|
||||
console.log(flatten(events))
|
||||
res.status(200).json(flatten(events));
|
||||
} else {
|
||||
res.status(404).json({message: "An error has occured"});
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const levenshtein = require("fast-levenshtein");
|
||||
|
||||
export function getClosest(input, list, limit=5){
|
||||
let t0 = performance.now();
|
||||
const things = []
|
||||
for (let s in list) {
|
||||
let ns = s.replaceAll("_"," ");
|
||||
|
@ -12,7 +11,5 @@ export function getClosest(input, list, limit=5){
|
|||
things.push({name: s, dist: levenshtein.get(input, ns)})
|
||||
}
|
||||
things.sort((a,b) => a.dist - b.dist);
|
||||
let t1 = performance.now();
|
||||
console.debug(`Levenshtein took ${t1-t0} ms`)
|
||||
return things.splice(0,limit);
|
||||
}
|
Loading…
Reference in a new issue