Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .github/workflows/_deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ jobs:
with:
fetch-depth: 0

- name: Checkout werf repo
uses: actions/checkout@v6
with:
repository: werf/werf
path: werf
fetch-depth: 0

- name: Inject trdl_channels.yaml
run: |
cp werf/trdl_channels.yaml .helm/trdl_channels.yaml

- name: Install werf
uses: werf/actions/install@v2
Expand Down Expand Up @@ -86,7 +76,6 @@ jobs:
env:
WERF_REPO: ghcr.io/${{ github.repository_owner }}/werfio-guides
WERF_STAGES_STORAGE: ghcr.io/werf/werfio-guides-stages
WERF_SET_ACTIVE_RELEASE: global.active_release=2
WERFIO_GITHUB_TOKEN: ${{ secrets.API_TOKEN }}
WERF_NAMESPACE: "werfio-production"
WERF_RELEASE: "werfio-site-production"
Expand Down
40 changes: 25 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,52 @@
name: Deploy

on:
push:
branches:
- chore/docs-major-routing
pull_request:
types: [labeled, synchronize]
workflow_dispatch:
inputs:
targetEnvironment:
description: "Target environment in dev cluster"
required: true
default: test
type: choice
options:
- test
- stage

env:
WERF_ENV: "production"
WERF_REPO: "ghcr.io/${{ github.repository_owner }}/werfio-guides"
WERF_STAGES_STORAGE: "ghcr.io/werf/werfio-guides-stages"
WERF_SET_ACTIVE_RELEASE: "global.active_release=2"
WERFIO_GITHUB_TOKEN: "${{ secrets.API_TOKEN }}"

jobs:
converge:
name: Deploy
if: contains(github.event.pull_request.labels.*.name, 'test website') || contains(github.event.pull_request.labels.*.name, 'stage website')
if: >-
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
(contains(github.event.pull_request.labels.*.name, 'test website') ||
contains(github.event.pull_request.labels.*.name, 'stage website')))
runs-on: prod-github-runner-0
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Checkout werf repo
uses: actions/checkout@v6
with:
repository: werf/werf
path: werf
fetch-depth: 0

- name: Inject trdl_channels.yaml
run: |
cp werf/trdl_channels.yaml .helm/trdl_channels.yaml

- name: Install werf
uses: werf/actions/install@v2

- name: Deploy to test
if: contains(github.event.pull_request.labels.*.name, 'test website')
if: >-
github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.targetEnvironment == 'test') ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'test website'))
run: |
. $(werf ci-env github --as-file)
werf converge
Expand All @@ -51,7 +59,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy to stage
if: contains(github.event.pull_request.labels.*.name, 'stage website')
if: >-
(github.event_name == 'workflow_dispatch' && github.event.inputs.targetEnvironment == 'stage') ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'stage website'))
run: |
. $(werf ci-env github --as-file)
werf converge
Expand Down
27 changes: 6 additions & 21 deletions .helm/templates/12-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ spec:
name: http
protocol: TCP
env:
- name: ACTIVE_RELEASE
value: {{ .Values.global.active_release | quote }}
- name: CURRENT_DOCS_MAJOR
value: {{ include "docsCurrentMajor" . | quote }}
- name: SUPPORTED_DOCS_MAJOR_VERSIONS
value: {{ include "docsSupportedRootsCSV" . | quote }}
- name: DOCS_LATEST_ALIAS_ENABLED
value: {{ include "docsLatestAliasEnabled" . | quote }}
- name: LOG_LEVEL
value: "info"
{{- if ne .Values.werf.env "production" }}
Expand All @@ -53,13 +57,6 @@ spec:
httpGet:
path: /health
port: 8080
volumeMounts:
- name: trdl-data
mountPath: /app/trdl
volumes:
- name: trdl-data
configMap:
name: trdl-data
---
apiVersion: v1
kind: Service
Expand Down Expand Up @@ -96,15 +93,3 @@ spec:
selector:
matchLabels:
service: backend
---
apiVersion: v1
kind: ConfigMap
metadata:
name: trdl-data
data:
trdl_channels.yaml: |
{{- if eq .Values.werf.env "production" }}
{{ .Files.Get "trdl_channels.yaml" | indent 4 }}
{{- else }}
{{ .Files.Get "trdl_channels-dev.yaml" | indent 4 }}
{{- end }}
53 changes: 53 additions & 0 deletions .helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,56 @@ affinity:
{{- end }}
{{- end }}

{{- define "docsCurrentMajor" -}}
{{- $current := pluck .Values.werf.env .Values.docsRouting.currentMajor | first | default .Values.docsRouting.currentMajor._default -}}
{{- $current = trim $current -}}
{{- $current = trimPrefix "/docs/" $current -}}
{{- $current = trimAll "/" $current -}}
{{- $current = lower $current -}}
{{- if hasPrefix "v" $current -}}
{{- $current -}}
{{- else -}}
{{- printf "v%s" $current -}}
{{- end -}}
{{- end }}

{{- define "docsSupportedRootsCSV" -}}
{{- $roots := pluck .Values.werf.env .Values.docsRouting.supportedRoots | first | default .Values.docsRouting.supportedRoots._default -}}
{{- $items := list (include "docsCurrentMajor" .) -}}
{{- range $root := $roots }}
{{- $normalized := trim $root -}}
{{- $normalized = trimPrefix "/docs/" $normalized -}}
{{- $normalized = trimAll "/" $normalized -}}
{{- $normalized = lower $normalized -}}
{{- if and $normalized (regexMatch "^v[0-9]+$" $normalized) (not (has $normalized $items)) -}}
{{- $items = append $items $normalized -}}
{{- end -}}
{{- end -}}
{{- join "," $items -}}
{{- end }}

{{- define "docsSupportedRootsPattern" -}}
{{- join "|" (splitList "," (include "docsSupportedRootsCSV" .)) -}}
{{- end }}

{{- define "docsLatestAliasEnabled" -}}
{{- $configured := pluck .Values.werf.env .Values.docsRouting.latestAliasEnabled | first | default .Values.docsRouting.latestAliasEnabled._default | default "auto" -}}
{{- $configured = lower (trim (printf "%v" $configured)) -}}
{{- if or (eq $configured "true") (eq $configured "1") (eq $configured "yes") (eq $configured "on") -}}
true
{{- else if or (eq $configured "false") (eq $configured "0") (eq $configured "no") (eq $configured "off") -}}
false
{{- else if eq (include "docsSupportedRootsCSV" .) "v1" -}}
false
{{- else -}}
true
{{- end -}}
{{- end }}

{{- define "docsModernStructuredRootsPattern" -}}
{{- $roots := without (splitList "," (include "docsSupportedRootsCSV" .)) "v1" -}}
{{- if gt (len $roots) 0 -}}
{{- join "|" $roots -}}
{{- end -}}
{{- end }}

Loading
Loading