Skip to content

Commit

Permalink
first draft of moving ci bash to GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
Christina Harlow committed Nov 24, 2021
1 parent ad4182a commit 610e3cd
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 324 deletions.
4 changes: 2 additions & 2 deletions ci/ct.yaml → .github/ct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ remote: origin
helm-extra-args: --timeout 600s
check-version-increment: true
validate-yaml: true
validate-chart-schema: false
validate-maintainers: false
validate-chart-schema: true
validate-maintainers: true
target-branch: main

chart-dirs:
Expand Down
112 changes: 112 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Lint & Test Charts

on: [ push, pull_request ]

jobs:
lint-test:
env:
NAMESPACE: "chart-ci-e2e"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0

# helm/chart-testing-action requires python version 3.7
# see: https://github.com/helm/chart-testing-action/issues/65
- uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Set up chart-testing
uses: helm/chart-testing-action@b0d4458c71155b54fcf33e11dd465dc923550009

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config .github/ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi
- name: Run chart-testing (lint)
run: ct lint --config .github/ct.yaml

- name: Create kind cluster
uses: helm/kind-action@v1.2.0
if: steps.list-changed.outputs.changed == 'true'

- name: Install Dependencies
if: steps.list-changed.outputs.changed == 'true'
run: |
set -e
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
#### CAREERS POSTGRES ####
helm upgrade --install \
--version 10.4.2 \
--namespace ${{ env.NAMESPACE }} \
--set postgresqlPassword=defaultpassword \
--set postgresqlUsername=careers \
--set postgresqlDatabase=careers \
--set fullnameOverride=careers-psql \
careers-psql bitnami/postgresql
#### CTMS POSTGRES ####
helm upgrade --install \
--version 10.4.2 \
--namespace ${{ env.NAMESPACE }} \
--set postgresqlPassword=defaultpassword \
--set postgresqlUsername=ctms \
--set postgresqlDatabase=ctms \
--set fullnameOverride=postgres \
postgresql bitnami/postgresql
#### DISCOURSE MYSQL, REDIS ####
helm upgrade --install \
--version 10.8.0 \
--namespace ${{ env.NAMESPACE }} \
--set fullnameOverride=discourse-psql \
--set persistence.enabled=false \
--set postgresqlDatabase=discourse \
--set postgresqlPassword=discourse-psql-password \
--set postgresqlUsername=postgres \
postgresql-discourse bitnami/postgresql
helm upgrade --install \
--version 14.8.6 \
--namespace ${{ env.NAMESPACE }} \
--set auth.enabled=true \
--set auth.password=discourse-redis-password \
--set fullnameOverride=discourse-redis \
--set persistence.enabled=false \
redis-discourse bitnami/redis
- name: Install ECR Secret
if: steps.list-changed.outputs.changed == 'true'
run: |
# Gets a valid token to pull from ECR and creates a secret with it
ACCOUNT=$(aws sts get-caller-identity --output text --query Account)
REGION=us-west-2
SECRET_NAME=ecr-registry
EMAIL=itse@mozilla.com
# Fetch token (which will expire in 12 hours)
TOKEN=$(aws ecr --region=$REGION get-authorization-token --output text --query authorizationData[].authorizationToken | base64 -d | cut -d: -f2)
# Create or replace secret
kubectl delete secret -n $NAMESPACE --ignore-not-found "$SECRET_NAME"
kubectl create secret -n $NAMESPACE docker-registry "$SECRET_NAME" \
--docker-server="https://${ACCOUNT}.dkr.ecr.${REGION}.amazonaws.com" \
--docker-username=AWS \
--docker-password="${TOKEN}" \
--docker-email="${EMAIL}"
- name: Run chart-testing (install)
run: ct install --config .github/ct.yaml
40 changes: 40 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release Charts

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "itse-automation"
git config user.email "itse-automation@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0

# https://github.com/helm/chart-releaser/issues/114
- name: Add Helm Repos for Dependencies
run: |
helm repo add elastic https://helm.elastic.co
helm repo add jetstack https://charts.jetstack.io
helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.2.1
with:
charts_dir: charts
charts_repo_url: https://mozilla-it.github.io/helm-charts/
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

19 changes: 0 additions & 19 deletions ci/deps/careers/install.sh

This file was deleted.

19 changes: 0 additions & 19 deletions ci/deps/ctms/install.sh

This file was deleted.

31 changes: 0 additions & 31 deletions ci/deps/discourse/install.sh

This file was deleted.

9 changes: 0 additions & 9 deletions ci/deps/install.sh

This file was deleted.

105 changes: 0 additions & 105 deletions ci/e2e.sh

This file was deleted.

Loading

0 comments on commit 610e3cd

Please sign in to comment.