Use cases
On this page
Using GRGate with Docker labels and Kubernetes
Docker labels can be used to gather information about running container and which repository and commit sha is attached to them. With this information, it is possible to provide back the state of the end-to-end tests via commit status. When all tests are successful, GRGate will automatically publish the release.
sequenceDiagram
participant Github repository application
participant Container registry
participant Kubernetes
participant GRGate
Github repository application -->> Container registry: build and publish Docker image
Github repository application -->> Github repository application: create draft release
Container registry -->> Kubernetes: deploy application in namespace
rect rgb(191, 223, 255)
note over Kubernetes: run e2e tests
end
loop each deployment in namespace
Kubernetes ->> Kubernetes: read container labels
Kubernetes ->> Github repository application: set commit status using GRGate CLI
end
Github repository application -->> GRGate: webhook events
GRGate -->> Github repository application: publish release
The steps below describe how to do it for a single container:
- build an app using Docker and attach metadata information to the image
- create a draft release
- image is pushed to a container registry which trigger a deployment of the container to a specific environment
- integration tests are run against the environment
- when it succeeds, update the commit status attached from the repository
- GRGate publish the release
In practice, let’s say we have an app built with Docker, we embed the repository and commit sha for reference later on:
FROM alpine
LABEL repository="my-organization/my-repository"
LABEL commitSha="abcd1234"
The repository would have a .grgate.yaml
config located in the root of the
repository:
statuses:
- e2e happy flow
After the image is built some task could automatically generate a draft release
and after the app is deployed to an environment, a system can run integration
tests against the image and when the tests succeeded and based on the
previously defined labels, we can use the grgate
cli to update the commit
statuses as follow:
repository=$(docker inspect my-app --format='{{.Config.Labels.repository}}')
commitSha=$(docker inspect my-app --format='{{.Config.Labels.commitSha}}')
grgate status set "$repository" \
--commit "$commitSha" \
--name "e2e happy flow" \
--status completed \
--state success
From there, if GRGate is listening to webhook, then the draft release will be published.