mirror of
https://github.com/mainnika/nikita-tokarch-uk.git
synced 2026-06-22 12:04:57 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
362920bccf
|
|||
|
571b8069e2
|
|||
|
55f3901e0d
|
|||
|
e1e852cece
|
|||
|
3a6bc59683
|
|||
|
576b795f5f
|
|||
|
a09e3e799e
|
@@ -2,7 +2,6 @@
|
|||||||
!cmd
|
!cmd
|
||||||
!nginx
|
!nginx
|
||||||
!pkg
|
!pkg
|
||||||
!templates
|
|
||||||
!web
|
!web
|
||||||
!go.mod
|
!go.mod
|
||||||
!go.sum
|
!go.sum
|
||||||
|
|||||||
@@ -22,26 +22,22 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.8'
|
python-version: '3.12'
|
||||||
|
|
||||||
- name: Install cosign
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: sigstore/cosign-installer@main
|
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Setup Docker buildx
|
- name: Setup Docker buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log into registry ${{ env.REGISTRY }}
|
- name: Log into registry ${{ env.REGISTRY }}
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -74,24 +70,19 @@ jobs:
|
|||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
id: build-and-push
|
id: build-and-push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
context: .
|
context: .
|
||||||
build-args: |
|
build-args: |
|
||||||
APP_VERSION=${{ steps.calver.outputs.current }}
|
APP_VERSION=${{ steps.calver.outputs.current }}
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
- name: Sign the published Docker image
|
|
||||||
if: ${{ github.event_name != 'pull_request' && !github.event.repository.private }}
|
|
||||||
env:
|
|
||||||
COSIGN_EXPERIMENTAL: "true"
|
|
||||||
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }}
|
|
||||||
|
|
||||||
- name: Trigger release job
|
- name: Trigger release job
|
||||||
if: ${{ success() && github.ref_name == 'main' && github.event_name != 'pull_request' && !github.event.repository.private }}
|
if: false
|
||||||
|
# if: ${{ success() && github.ref_name == 'main' && github.event_name != 'pull_request' && !github.event.repository.private }}
|
||||||
uses: toptal/jenkins-job-trigger-action@master
|
uses: toptal/jenkins-job-trigger-action@master
|
||||||
with:
|
with:
|
||||||
jenkins_url: ${{ secrets.JENKINS_URL }}
|
jenkins_url: ${{ secrets.JENKINS_URL }}
|
||||||
|
|||||||
Vendored
+5
-3
@@ -1,10 +1,10 @@
|
|||||||
def HELM_DOWNLOAD_URL = "https://get.helm.sh/helm-v3.7.2-linux-amd64.tar.gz"
|
def HELM_DOWNLOAD_URL = "https://get.helm.sh/helm-v3.14.0-linux-amd64.tar.gz"
|
||||||
def WS_DIST = ".dist"
|
def WS_DIST = ".dist"
|
||||||
def WS_BIN = ".bin"
|
def WS_BIN = ".bin"
|
||||||
def WS_SCM = ".scm"
|
def WS_SCM = ".scm"
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent { label "k8s" }
|
agent { label "kube0" }
|
||||||
|
|
||||||
parameters {
|
parameters {
|
||||||
string(
|
string(
|
||||||
@@ -40,7 +40,8 @@ pipeline {
|
|||||||
dir("${WS_DIST}") {
|
dir("${WS_DIST}") {
|
||||||
sh """
|
sh """
|
||||||
curl -fsSL -O "${HELM_DOWNLOAD_URL}";
|
curl -fsSL -O "${HELM_DOWNLOAD_URL}";
|
||||||
tar xfz -C "${env.WORKSPACE}/${WS_BIN}" *;
|
mkdir -p "${env.WORKSPACE}/${WS_BIN}";
|
||||||
|
tar xfz * -C "${env.WORKSPACE}/${WS_BIN}";
|
||||||
ls -lah "${env.WORKSPACE}/${WS_BIN}/linux-amd64/helm";
|
ls -lah "${env.WORKSPACE}/${WS_BIN}/linux-amd64/helm";
|
||||||
"""
|
"""
|
||||||
deleteDir()
|
deleteDir()
|
||||||
@@ -73,6 +74,7 @@ pipeline {
|
|||||||
sh """
|
sh """
|
||||||
"${env.WORKSPACE}/${WS_BIN}/linux-amd64/helm" upgrade ${params.RELEASE_NAME} * \
|
"${env.WORKSPACE}/${WS_BIN}/linux-amd64/helm" upgrade ${params.RELEASE_NAME} * \
|
||||||
--namespace ${params.RELEASE_NAMESPACE} \
|
--namespace ${params.RELEASE_NAMESPACE} \
|
||||||
|
--install \
|
||||||
--create-namespace \
|
--create-namespace \
|
||||||
--dependency-update \
|
--dependency-update \
|
||||||
--reset-values \
|
--reset-values \
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ RUN dnf install -yq golang
|
|||||||
|
|
||||||
COPY go.mod .
|
COPY go.mod .
|
||||||
COPY go.sum .
|
COPY go.sum .
|
||||||
COPY templates/go.mod templates/go.mod
|
|
||||||
COPY templates/go.sum templates/go.sum
|
|
||||||
|
|
||||||
RUN --mount=type=cache,id=gopath,target=${GOPATH} \
|
RUN --mount=type=cache,id=gopath,target=${GOPATH} \
|
||||||
go mod \
|
go mod \
|
||||||
@@ -20,7 +18,6 @@ ARG APP_VERSION=containerized
|
|||||||
|
|
||||||
COPY cmd cmd
|
COPY cmd cmd
|
||||||
COPY pkg pkg
|
COPY pkg pkg
|
||||||
COPY templates templates
|
|
||||||
|
|
||||||
RUN --mount=type=cache,id=gopath,target=${GOPATH} \
|
RUN --mount=type=cache,id=gopath,target=${GOPATH} \
|
||||||
go build \
|
go build \
|
||||||
|
|||||||
@@ -9,11 +9,10 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
|
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
|
|
||||||
|
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/v4api/httpclient"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/v4api/httpclient"
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/routes"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/routes"
|
||||||
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "nightly"
|
var Version = "nightly"
|
||||||
@@ -53,7 +52,7 @@ func main() {
|
|||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
templateFuncs := &templates.Funcs{Version: Version, YandexKey: config.Site.YandexKey}
|
templateFuncs := &templates.Funcs{Version: Version, Site: config.Site}
|
||||||
err = templates.Load(templateFuncs)
|
err = templates.Load(templateFuncs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
|||||||
@@ -2,10 +2,7 @@ module code.tokarch.uk/mainnika/nikita-tokarch-uk
|
|||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
replace code.tokarch.uk/mainnika/nikita-tokarch-uk/templates => ./templates
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
code.tokarch.uk/mainnika/nikita-tokarch-uk/templates v0.0.0-00010101000000-000000000000
|
|
||||||
github.com/jackwhelpton/fasthttp-routing/v2 v2.0.0
|
github.com/jackwhelpton/fasthttp-routing/v2 v2.0.0
|
||||||
github.com/mailru/easyjson v0.7.7
|
github.com/mailru/easyjson v0.7.7
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
|
|||||||
+1
-2
@@ -6,10 +6,9 @@ import (
|
|||||||
routing "github.com/jackwhelpton/fasthttp-routing/v2"
|
routing "github.com/jackwhelpton/fasthttp-routing/v2"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
|
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
|
|
||||||
|
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content"
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params"
|
||||||
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
// relativeRedirectBytes makes a relative redirect by using http Location header
|
// relativeRedirectBytes makes a relative redirect by using http Location header
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
routing "github.com/jackwhelpton/fasthttp-routing/v2"
|
routing "github.com/jackwhelpton/fasthttp-routing/v2"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
|
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ routing.DataWriter = (*TemplateWriter)(nil)
|
var _ routing.DataWriter = (*TemplateWriter)(nil)
|
||||||
|
|||||||
@@ -6,10 +6,9 @@ import (
|
|||||||
routing "github.com/jackwhelpton/fasthttp-routing/v2"
|
routing "github.com/jackwhelpton/fasthttp-routing/v2"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
|
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/templates"
|
|
||||||
|
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost"
|
||||||
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Routes is the main handler that contains all routes handlers
|
// Routes is the main handler that contains all routes handlers
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ import (
|
|||||||
"html/template"
|
"html/template"
|
||||||
"net/url"
|
"net/url"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Funcs struct {
|
type Funcs struct {
|
||||||
Version string
|
Version string
|
||||||
|
Site config.Site
|
||||||
YandexKey string
|
|
||||||
|
|
||||||
compiledJSAppURL string
|
compiledJSAppURL string
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ func (f *Funcs) getBlogURL() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Funcs) getYaKey() string {
|
func (f *Funcs) getYaKey() string {
|
||||||
return f.YandexKey
|
return f.Site.YandexKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use returns a func map with template helpers functions
|
// Use returns a func map with template helpers functions
|
||||||
@@ -21,10 +21,10 @@ import (
|
|||||||
//go:embed analytics.go.tmpl
|
//go:embed analytics.go.tmpl
|
||||||
var content embed.FS
|
var content embed.FS
|
||||||
|
|
||||||
// Templates is a container of compiled templates
|
// List of compiled go-templates
|
||||||
var Templates *template.Template = template.New("")
|
var Templates *template.Template = template.New("")
|
||||||
|
|
||||||
// Load embedded templates
|
// Load embeded templates
|
||||||
func Load(funcs *Funcs) (err error) {
|
func Load(funcs *Funcs) (err error) {
|
||||||
|
|
||||||
Templates.Funcs(funcs.Use())
|
Templates.Funcs(funcs.Use())
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
module code.tokarch.uk/mainnika/nikita-tokarch-uk/templates
|
|
||||||
|
|
||||||
go 1.17
|
|
||||||
|
|
||||||
require github.com/sirupsen/logrus v1.8.1
|
|
||||||
|
|
||||||
require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
||||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
|
||||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
|
||||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
|
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
Reference in New Issue
Block a user