Skip to content

Commit

Permalink
Merge pull request #13 from dirodriguezm/helm-chart
Browse files Browse the repository at this point in the history
Add helm chart and deployment commands
  • Loading branch information
dirodriguezm authored Sep 7, 2024
2 parents 920b3b0 + 97f2c4f commit 213070a
Show file tree
Hide file tree
Showing 30 changed files with 1,109 additions and 170 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/deploy_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Deploy Staging
on:
release:
types: [prereleased]

jobs:
deploy-staging:
name: deploy-staging
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
id: creds
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_ROLE_STAGING }}
aws-region: us-east-1
output-credentials: true
unset-current-credentials: true
-
name: Call Dagger Deploy Function
uses: dagger/dagger-for-github@v5
with:
version: "latest"
verb: call
args: deploy-helm-charts --username=${{github.actor}} --password=${{secrets.GITHUB_TOKEN}} --helm-values=ssm:tapservice-values-staging --version=24.9.0
workdir: ./ci
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Publish
on:
push:
branches: [main]

jobs:
publish:
name: publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
-
name: Call Dagger Publish Function
uses: dagger/dagger-for-github@v5
with:
version: "latest"
verb: call
args: publish-images --rootDir=.. --username=${{github.actor}} --password=${{secrets.GITHUB_TOKEN}} --tags=rc
workdir: ./ci
-
name: Call Dagger Publish Helm Charts Function
uses: dagger/dagger-for-github@v5
with:
version: "latest"
verb: call
args: publish-helm-charts --rootDir=.. --username=${{github.actor}} --password=${{github.token}}
workdir: ./ci
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
-
name: Call Dagger Build Function
uses: dagger/dagger-for-github@v5
with:
version: "latest"
verb: call
args: build --rootDir=..
workdir: ./ci
-
name: Call Dagger Test Function
uses: dagger/dagger-for-github@v5
Expand Down
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
vendor/

# Go workspace file
go.work

# build directory
ataps

# Helm chart values file
values-override.yaml

# Local environment variables file
.env
22 changes: 15 additions & 7 deletions ci/dagger/go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module dagger/ci

go 1.22.3
go 1.23.0

require (
github.com/99designs/gqlgen v0.17.44
github.com/99designs/gqlgen v0.17.49
github.com/Khan/genqlient v0.7.0
github.com/vektah/gqlparser/v2 v2.5.11
github.com/vektah/gqlparser/v2 v2.5.16
go.opentelemetry.io/otel v1.27.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
Expand All @@ -28,13 +28,21 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sosodev/duration v1.2.0 // indirect
github.com/sosodev/duration v1.3.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
google.golang.org/protobuf v1.34.1 // indirect
)

replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88

replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0

replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.3.0

replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.3.0
24 changes: 12 additions & 12 deletions ci/dagger/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/99designs/gqlgen v0.17.44 h1:OS2wLk/67Y+vXM75XHbwRnNYJcbuJd4OBL76RX3NQQA=
github.com/99designs/gqlgen v0.17.44/go.mod h1:UTCu3xpK2mLI5qcMNw+HKDiEL77it/1XtAjisC4sLwM=
github.com/99designs/gqlgen v0.17.49 h1:b3hNGexHd33fBSAd4NDT/c3NCcQzcAVkknhN9ym36YQ=
github.com/99designs/gqlgen v0.17.49/go.mod h1:tC8YFVZMed81x7UJ7ORUwXF4Kn6SXuucFqQBhN8+BU0=
github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w=
github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
Expand Down Expand Up @@ -27,14 +27,14 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/sosodev/duration v1.2.0 h1:pqK/FLSjsAADWY74SyWDCjOcd5l7H8GSnnOGEB9A1Us=
github.com/sosodev/duration v1.2.0/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4=
github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vektah/gqlparser/v2 v2.5.11 h1:JJxLtXIoN7+3x6MBdtIP59TP1RANnY7pXOaDnADQSf8=
github.com/vektah/gqlparser/v2 v2.5.11/go.mod h1:1rCcfwB2ekJofmluGWXMSEnPMZgbxzwj6FaZ/4OT8Cc=
github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0vy5p8=
github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg=
go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4=
Expand Down Expand Up @@ -63,14 +63,14 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 h1:P8OJ/WCl/Xo4E4zoe4/bifHpSmmKwARqyqE4nW6J2GQ=
google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5/go.mod h1:RGnPtTG7r4i8sPlNyDeikXF99hMM+hN6QMm4ooG9g2g=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 h1:AgADTJarZTBqgjiUzRgfaBchgYB3/WFTC80GPwsMcRI=
Expand Down
119 changes: 106 additions & 13 deletions ci/dagger/main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
// A generated module for Ci functions
//
// This module has been generated via dagger init and serves as a reference to
// basic module structure as you get started with Dagger.
//
// Two functions have been pre-created. You can modify, delete, or add to them,
// as needed. They demonstrate usage of arguments and return types using simple
// echo and grep commands. The functions can be called from the dagger CLI or
// from one of the SDKs.
//
// The first line in this comment block is a short description line and the
// rest is a long description with more detail on the module's purpose or usage,
// if appropriate. All modules should have a short description.
// Monorepo level CI/CD for packages

package main

import (
"context"
"fmt"
)

type Ci struct{}
Expand All @@ -24,3 +13,107 @@ type Ci struct{}
func (m *Ci) Test(ctx context.Context, rootDir *Directory) (string, error) {
return dag.Tapservicego().Test(ctx, rootDir.Directory("tapservicego"))
}

// Build all packages
func (m *Ci) Build(ctx context.Context, rootDir *Directory) (string, error) {
return dag.Tapservicego().Build(rootDir.Directory("tapservicego"), 8080).Stdout(ctx)
}

// Publish container images
func (m *Ci) PublishImages(ctx context.Context, rootDir *Directory, username string, password *Secret, tags string) (string, error) {
images, err := m.publishTapservice(ctx, rootDir, username, password, tags)
if err != nil {
return "", err
}
result := "Published images:\n"
for _, image := range images {
result += image + "\n"
}
return result, nil
}

// Publish Helm Charts
func (m *Ci) PublishHelmCharts(
ctx context.Context,
rootDir *Directory,
username string,
password *Secret,
ghOrg *string,
) (string, error) {
var result string
output, err := m.publishTapserviceHelmChart(ctx, rootDir, username, password, ghOrg)
if err != nil {
return "", err
}
result += output + "\n"
return result, nil
}

// Deploy Helm Charts
func (m *Ci) DeployHelmCharts(
ctx context.Context,
username string,
password *Secret,
helmValues *string,
version string,
dryRun bool,
) (string, error) {
var result string
container := m.deployTapService(username, password, helmValues, version, dryRun)
output, err := container.Stdout(ctx)
if err != nil {
return "", err
}
result += output + "\n"
return result, nil
}

func (m *Ci) deployTapService(username string, password *Secret, helmValues *string, version string, dryRun bool) *Container {
opts := TapservicegoDeployOpts{
HelmValues: *helmValues,
}
url := "ghcr.io/%s/tapservice-chart/tapservice:%s"
url = fmt.Sprintf(url, username, version)
return dag.Tapservicego().Deploy(username, password, url, dryRun, opts)
}

func (m *Ci) publishTapservice(
ctx context.Context,
rootDir *Directory,
username string,
password *Secret,
tags string,
) ([]string, error) {
tapOptions := TapservicegoPublishContainerOpts{
Username: username,
Tags: tags,
}
images, err := dag.Tapservicego().PublishContainer(
ctx,
rootDir.Directory("tapservicego"),
password,
tapOptions,
)
if err != nil {
return []string{}, err
}
return images, nil
}

func (m *Ci) publishTapserviceHelmChart(
ctx context.Context,
rootDir *Directory,
username string,
password *Secret,
ghOrg *string,
) (string, error) {
chartDir := rootDir.Directory("tapservicego").Directory("deployments/tapservice")
var org string
if ghOrg == nil {
org = username
}
opts := TapservicegoPublishHelmChartOpts{
GhOrg: org,
}
return dag.Tapservicego().PublishHelmChart(ctx, chartDir, username, password, opts)
}
Loading

0 comments on commit 213070a

Please sign in to comment.