Skip to content

Commit

Permalink
Push commit hash docker image on pushes to main (#768)
Browse files Browse the repository at this point in the history
* Push commit hash docker image on pushes to main
grafana/tanka:${commit}
This will allow us to use Tanka faster without releasing, leading to less bugs in releases

* Use manifest instead of docker
We need to have the arm images as well
  • Loading branch information
julienduchesne authored Sep 28, 2022
1 parent 904a7c5 commit e53e74b
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 23 deletions.
70 changes: 48 additions & 22 deletions .drone/drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,29 @@ local pipeline(name) = {
steps: [],
};

local docker(arch) = pipeline('docker-' + arch) {
platform: {
os: 'linux',
arch: arch,
},
steps: [
go('fetch-tags', ['git fetch origin --tags']),
make('static'),
{
name: 'container',
image: 'plugins/docker',
settings: {
repo: 'grafana/tanka',
auto_tag: true,
auto_tag_suffix: arch,
username: { from_secret: vault.dockerhub_username },
password: { from_secret: vault.dockerhub_password },
},
local docker(arch, depends_on=[]) =
pipeline('docker-' + arch) {
platform: {
os: 'linux',
arch: arch,
},
],
};
steps: [
go('fetch-tags', ['git fetch origin --tags']),
make('static'),
{
name: 'container',
image: 'plugins/docker',
settings: {
repo: 'grafana/tanka',
auto_tag: true,
auto_tag_suffix: arch,
username: { from_secret: vault.dockerhub_username },
password: { from_secret: vault.dockerhub_password },
},
},
],
depends_on: depends_on,
};

[
pipeline('check') {
Expand Down Expand Up @@ -92,8 +94,32 @@ local docker(arch) = pipeline('docker-' + arch) {
],
} + { depends_on: ['check'] } + constraints.tags,

docker('amd64') { depends_on: ['check'] } + constraints.tags + constraints.mainPush,
docker('arm64') { depends_on: ['check'] } + constraints.tags + constraints.mainPush,
docker('amd64', depends_on=['check']) + constraints.tags + constraints.mainPush,
docker('arm64', depends_on=['check']) + constraints.tags + constraints.mainPush,

pipeline('manifest-main') {
steps: [
go('fetch-tags', [
'git fetch origin --tags',
'echo "main-$(git describe --tags)" > .tags',
]),
{
name: 'manifest',
image: 'plugins/manifest',
settings: {
ignore_missing: true,
spec: '.drone/docker-manifest.tmpl',
username: { from_secret: vault.dockerhub_username },
password: { from_secret: vault.dockerhub_password },
},
},
],
} + {
depends_on: [
'docker-amd64',
'docker-arm64',
],
} + constraints.mainPush,

pipeline('manifest') {
steps: [{
Expand Down
32 changes: 31 additions & 1 deletion .drone/drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,36 @@ depends_on:
- docker-amd64
- docker-arm64
kind: pipeline
name: manifest-main
steps:
- commands:
- git fetch origin --tags
- echo "main-$(git describe --tags)" > .tags
image: golang:1.19
name: fetch-tags
volumes:
- name: gopath
path: /go
- image: plugins/manifest
name: manifest
settings:
ignore_missing: true
password:
from_secret: dockerhub_password
spec: .drone/docker-manifest.tmpl
username:
from_secret: dockerhub_username
trigger:
ref:
- refs/heads/main
volumes:
- name: gopath
temp: {}
---
depends_on:
- docker-amd64
- docker-arm64
kind: pipeline
name: manifest
steps:
- image: plugins/manifest
Expand Down Expand Up @@ -252,6 +282,6 @@ kind: secret
name: dockerhub_password
---
kind: signature
hmac: 9d1c433944d46ded93d8637f570568e8a9e9887d4a4b3c790a25e9c83cd58921
hmac: adbd6c28d92efbf2968766102c5abe0bbad5a4af1c76e84ada59b2c5cf9c958d

...

0 comments on commit e53e74b

Please sign in to comment.