Skip to content

Commit

Permalink
Added: ci functionality to push helm charts to github pages
Browse files Browse the repository at this point in the history
***What does this PR do?***

  - Installs helm chart releaser in CI
  - Adds stage to CI to publish changed charts to github pages

***Why is this PR needed?***

  - Ensure that published charts are accessible via helm repo
  • Loading branch information
stephenmoloney committed Dec 27, 2020
1 parent 0607f20 commit 0dab109
Show file tree
Hide file tree
Showing 19 changed files with 371 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/templates/01_lint.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# @format
---
stages:
- stage: Lint
- stage: lint
displayName: Lint codebase
condition: and(
ne(variables['Build.SourceBranch'], 'refs/heads/master'),
Expand Down
4 changes: 2 additions & 2 deletions .azure-pipelines/templates/02_docker_build.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# @format
---
stages:
- stage: Build
- stage: docker_build
displayName: Build images
condition: and(
ne(variables['Build.SourceBranch'], 'refs/heads/master'),
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
)
dependsOn: []
dependsOn: [lint]
jobs:
- job: build_saleor_core
displayName: Build saleor-core image
Expand Down
2 changes: 1 addition & 1 deletion .azure-pipelines/templates/03_docker_push.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# @format
---
stages:
- stage: Push
- stage: docker_push
displayName: Push images
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
dependsOn: []
Expand Down
53 changes: 53 additions & 0 deletions .azure-pipelines/templates/04_helm_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# @format
---
stages:
- stage: helm_push
displayName: Push saleor helm charts
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
dependsOn: []
jobs:
- deployment: helm_push_approval
displayName: Approval for push to registry
dependsOn: []
continueOnError: false
timeoutInMinutes: 1296000
cancelTimeoutInMinutes: 1296000
environment: "Push saleor helm charts"
strategy:
runOnce:
deploy:
steps:
- script: echo "approval required"

- job: push_saleor_helm_charts
displayName: Push saleor helm charts to github pages
dependsOn: [helm_push_approval]
condition: succeeded()
steps:
- template: ../init_step.yaml

- task: Bash@3
displayName: Configure git
inputs:
targetType: "inline"
workingDirectory: "$(Build.Repository.LocalPath)"
failOnStderr: false
noProfile: true
noRc: true
script: |
git config --global user.name "eirenauts-infra"
git config --global user.email "[email protected]"
- task: Bash@3
displayName: Push saleor helm charts
inputs:
targetType: "inline"
workingDirectory: "$(Build.Repository.LocalPath)"
failOnStderr: false
noProfile: true
noRc: true
script: |
make push_updated_charts
env:
CR_TOKEN: $(crToken)

21 changes: 21 additions & 0 deletions .cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# @format

owner: eirenauts
git-repo: saleor-k8s
charts-repo: https://eirenauts.github.io/saleor-k8s
# index-path: .packaged/index.yaml
index-path: index.yaml
package-path: .packaged
# sign
# key
# keyring
# passphrase-file
# token
git-base-url: https://api.github.com/
git-upload-url: https://uploads.github.com/
# commit
pages-branch: gh-pages
push: true
pr: false
remote: origin
# release-name-template
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ saleor_core_dev
saleor_dashboard
saleor_storefront
charts/saleor-platform/charts
charts/saleor-platform/tmpcharts
charts/saleor-platform/Chart.lock
downloads
*-x86_64
index.yaml
.packaged
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ saleor_core/**
saleor_core_dev/**
saleor_dashboard/**
saleor_storefront/**
downloads/**
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SHELL := /bin/bash
init_docker \
init_docker_compose \
init_hadolint \
init_chart_releaser \
init_all \
format_all \
lint_all \
Expand All @@ -21,7 +22,9 @@ SHELL := /bin/bash
push_saleor_dashboard \
push_saleor_storefront \
get_image \
get_image_version
get_image_version \
push_image \
push_updated_charts


## Dependency installation targets
Expand Down Expand Up @@ -55,14 +58,18 @@ init_docker_compose:
init_hadolint:
if [ -z "$$(command -v install_hadolint)" ]; then ./scripts/make.sh install_hadolint "${HADOLINT_VERSION}"; fi

init_chart_releaser:
if [ -z "$$(command -v cr)" ]; then ./scripts/make.sh install_helm_chart_releaser "${CHART_RELEASER_VERSION}"; fi

init_all: \
init_yarn \
init_go \
init_shfmt \
init_shellcheck \
init_docker \
init_docker_compose \
init_hadolint
init_hadolint \
init_chart_releaser

## Code consistency/quality targets

Expand Down Expand Up @@ -204,7 +211,7 @@ push_saleor_core_dev:
"ghcr.io/eirenauts/saleor-core:dev-latest"
echo "${REGISTRY_TOKEN}" | docker login ghcr.io -u eirenauts --password-stdin
make -s push_image \
IMAGE_VERSION="$$(make -s get_image_version SALEOR_REPO=https://github.com/mirumee/saleor.git)" \
IMAGE_VERSION="dev-$$(make -s get_image_version SALEOR_REPO=https://github.com/mirumee/saleor.git)" \
DOCKER_REPO=saleor-core \
FORCE_PUSH="${FORCE_PUSH_IMAGES}"
docker logout ghcr.io
Expand Down Expand Up @@ -247,3 +254,10 @@ push_saleor_storefront:
FORCE_PUSH="${FORCE_PUSH_IMAGES}"
docker logout ghcr.io
if [[ -e /home/vsts/.docker/config.json ]]; then rm /home/vsts/.docker/config.json; fi

push_updated_charts:
@if test -z "$(CR_TOKEN)"; then \
echo "env variable CR_TOKEN is required" && \
exit 1; \
fi;
./scripts/make.sh package_newly_versioned_charts "${CR_TOKEN}"
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
# saleor-k8s

[![Build Status](https://dev.azure.com/eirenauts/saleor-k8s/_apis/build/status/eirenauts.saleor-k8s?branchName=master)](https://dev.azure.com/eirenauts/saleor-k8s/_build/latest?definitionId=1&branchName=master) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://choosealicense.com/licenses/apache-2.0/)

## saleor charts

## saleor containers
The umbrella chart required to deploy the entire saleor ecommerce platform is the `saleor-platform` chart.

### List of charts

| Chart Name | Notes |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| saleor-core | Handles deployment of `saleor-core` application. Includes a number of jobs for initialization tasks, backups and restore. |
| saleor-dashboard | Handles deployment of `saleor-dashboard` application as an nginx application. Required for the front end admin dashboard. |
| saleor-storefront | Handles deployment of `saleor-dashboard` application as an nginx application. Required for the front end UI where customers land. |
| saleor-platform | This is an umbrella chart. It does not deploy any single application but rather is deploys a collection of subcharts required for saleor to function. |

### Example helm deployment

There is freedom to deploy the `saleor-platform` chart in a number of different ways - not all of which have been tested out.

[![Build Status](https://dev.azure.com/eirenauts/saleor-k8s/_apis/build/status/eirenauts.saleor-k8s?branchName=master)](https://dev.azure.com/eirenauts/saleor-k8s/_build/latest?definitionId=1&branchName=master) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://choosealicense.com/licenses/apache-2.0/) ![Semver Version](https://img.shields.io/github/v/tag/eirenauts/saleor-k8s?color=blue&sort=semver)
An example deployment is illustrated here.

This repository is a collection of build files for the saleor container images.
TODO

### List of Images

| Image | Version | Base Image | Key Components | Purpose |
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| [saleor-core](https://github.com/users/eirenauts/packages/saleor-k8s/package/saleor-core) | [![Docker Version](https://img.shields.io/badge/version-1.3.0-blue)](https://github.com/users/eirenauts/packages/saleor-k8s/package/saleor-core) | `python:3.8.6-slim` | `saleor core application - django, graphql, ecommerce app` | Backend for the saleor platform. Required for k8s deployments. |
| [saleor-dashboard](https://github.com/users/eirenauts/packages/saleor-k8s/package/saleor-dashboard) | [![Docker Version](https://img.shields.io/badge/version-1.3.0-blue)](https://github.com/users/eirenauts/packages/saleor-k8s/package/saleor-dashboard) | `nginxinc/nginx-unprivileged:1.19.5` | `javascript, reactjs` | Frontend for the admin dashboard for the saleor platform. Required for k8s deployments. |
| [saleor-storefront](https://github.com/users/eirenauts/packages/saleor-k8s/package/saleor-storefront) | [![Docker Version](https://img.shields.io/badge/version-1.3.0-blue)](https://github.com/users/eirenauts/packages/saleor-k8s/package/saleor-storefront) | `nginxinc/nginx-unprivileged:1.19.5` | `javascript, reactjs` | Default frontend for the storefront for the saleor platform. Required for k8s deployments. Fork this if it is necessary to create a custom UI. |
| Image | Version | Base Image | Key Components | Purpose |
| ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| [saleor-core](https://github.com/users/eirenauts/packages/container/package/saleor-core) | [![Docker Version](https://img.shields.io/badge/version-2.11.1-blue)](https://github.com/users/eirenauts/packages/container/package/saleor-core) | `python:3.8.6-slim` | `saleor core application - django, graphql, ecommerce app` | Backend for the saleor platform. Required for k8s deployments. |
| [saleor-dashboard](https://github.com/users/eirenauts/packages/container/package/saleor-dashboard) | [![Docker Version](https://img.shields.io/badge/version-2.11.1-blue)](https://github.com/users/eirenauts/packages/container/package/saleor-dashboard) | `nginxinc/nginx-unprivileged:1.19.5` | `javascript, reactjs` | Frontend for the admin dashboard for the saleor platform. Required for k8s deployments. |
| [saleor-storefront](https://github.com/users/eirenauts/packages/container/package/saleor-storefront) | [![Docker Version](https://img.shields.io/badge/version-2.11.1-blue)](https://github.com/users/eirenauts/packages/container/package/saleor-storefront) | `nginxinc/nginx-unprivileged:1.19.5` | `javascript, reactjs` | Default frontend for the storefront for the saleor platform. Required for k8s deployments. Fork this if it is necessary to create a custom UI. |

## Licence

Expand Down
2 changes: 2 additions & 0 deletions azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ variables:
DOCKER_VERSION: 20.10.0
DOCKER_COMPOSE_VERSION: 1.27.4
HADOLINT_VERSION: 1.19.0
CHART_RELEASER_VERSION: 1.1.1

stages:
- template: .azure-pipelines/templates/01_lint.yaml
- template: .azure-pipelines/templates/02_docker_build.yaml
- template: .azure-pipelines/templates/03_docker_push.yaml
- template: .azure-pipelines/templates/04_helm_push.yaml
2 changes: 1 addition & 1 deletion charts/saleor-core/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: v2
name: saleor-core
description: A Helm chart for deploying the saleor core application in Kubernetes
type: application
version: 0.1.0
version: 0.0.1
appVersion: 2.11.1
kubeVersion: ">=1.9.0"
keywords:
Expand Down
2 changes: 1 addition & 1 deletion charts/saleor-dashboard/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: v2
name: saleor-dashboard
description: A Helm chart for deploying the saleor dashboard application in Kubernetes
type: application
version: 0.1.0
version: 0.0.1
appVersion: 2.11.1
kubeVersion: ">=1.9.0"
keywords:
Expand Down
21 changes: 0 additions & 21 deletions charts/saleor-platform/Chart.lock

This file was deleted.

17 changes: 7 additions & 10 deletions charts/saleor-platform/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: v2
name: saleor-platform
description: A Helm chart for deploying the entire umbrella of saleor charts
type: application
version: 0.1.0
version: 0.0.1
appVersion: 2.11.1
kubeVersion: ">=1.9.0"
keywords:
Expand Down Expand Up @@ -54,9 +54,8 @@ dependencies:
## 2. Pods for the web server (for static assets and media assets) if not using cloud storage
## 3. Pods for the celery workers which execute particular tasks on demand
- name: saleor-core
version: "1.0.0"
# repository: "https://rg.fr-par.scw.cloud/private-helm-repo-scw-prod/saleor-core"
repository: "file:///home/u1/Documents/repos/saleor-components/saleor-k8s-intermediate/charts/saleor-core"
version: "0.0.1"
repository: "https://eirenauts.github.io/saleor-k8s"
condition: saleor-core.enabled
tags:
- workers
Expand All @@ -65,19 +64,17 @@ dependencies:

## Notes: This is a web server of pre-built static assets and emails for the storefront which customers see
- name: saleor-storefront
version: "1.0.0"
# repository: "https://rg.fr-par.scw.cloud/private-helm-repo-scw-prod/saleor-storefront"
repository: "file:///home/u1/Documents/repos/saleor-components/saleor-k8s-intermediate/charts/saleor-storefront"
version: "0.0.1"
repository: "https://eirenauts.github.io/saleor-k8s"
condition: saleor-storefront.enabled
tags:
- ui
- storefront

## Notes: This is a web server of pre-built static assets for the administrative dashboard
- name: saleor-dashboard
version: "1.0.0"
# repository: "https://rg.fr-par.scw.cloud/private-helm-repo-scw-prod/saleor-dashboard"
repository: "file:///home/u1/Documents/repos/saleor-components/saleor-k8s-intermediate/charts/saleor-dashboard"
version: "0.0.1"
repository: "https://eirenauts.github.io/saleor-k8s"
condition: saleor-dashboard.enabled
tags:
- ui
Expand Down
2 changes: 1 addition & 1 deletion charts/saleor-storefront/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: v2
name: saleor-storefront
description: A Helm chart for deploying the saleor storefront application in Kubernetes
type: application
version: 0.1.0
version: 0.0.1
appVersion: 2.11.1
kubeVersion: ">=1.9.0"
keywords:
Expand Down
Loading

0 comments on commit 0dab109

Please sign in to comment.