Join our community Discord , if you need some help.

Automatically deploy your application to staging

In this guide you will set up a deploy policy to automatically deploy every new git commit to staging.


Automating staging deploys

To deploy every new main branch commit to staging, add the following deploy policy section to the .gimlet/staging.yaml file.

Also, change your image tag to follow your image tagging convention

# .gimlet/staging.yaml
app: frontend
env: staging
namespace: my-team
+ branch: main
+ event: push
name: onechart
version: 0.32.0
replicas: 2
repository: myapp
- tag: 1.1.0
+ tag: "{{ .GITHUB_SHA }}"
tlsEnabled: true

Gimlet supports multiple deploy conditions, but before this is going to work, you have to set up the missing link between your CI and Gimlet. Let's set it up now, shall we?

Before Gimlet can act on your new commits, it must know about every new artifact you build.

Your CI typically

  • runs tests
  • builds your app
  • and also builds a docker image

When it is ready with all that, it must signal Gimlet that there is a new releasable application version.

To do that, you have to extend your CI pipeline with an explicit step that ships this information to Gimlet.

Shipping artifact information to Gimlet

Gimlet has CI plugins that ship the needed artifact information.

First, set the GIMLET_SERVER and GIMLET_TOKEN secrets for your repository. These are GimletD API access credentials that you can get from your cluster administrator.

Then alter your Github Action pipeline to ship the artifact to GimletD.

name: Build
- 'main'

runs-on: ubuntu-latest
name: "Shipping artifact"
- docker-build
- name: Check out
uses: actions/checkout@v1
fetch-depth: 1
+ - name: Shipping release artifact to Gimlet
+ id: shipping
+ uses: gimlet-io/gimlet-artifact-shipper-action@v0.4.2
+ env:

If you do so, your Github Action will ship an artifact after everty docker image build.

Github Action shipping a Gimlet artifcat

Verify the shipped artifact

To verify the shipped artifact, use the Gimlet CLI:

$ export GIMLET_SERVER=<<Gimlet server URL>>
$ export GIMLET_TOKEN=<<Gilmet API token>>

$ gimlet artifact list

1c3f577a - Just another monorepo commit (3 weeks ago) Laszlo Fogas
myapp -> staging @ push

By now, if GimletD is in place, it also already released your app to staging. Verify the latest commit in the gitops repo to see of GimletD had made the change, and on Kubernetes to see your updated application.