Skip to content

Commit 3ae47b4

Browse files
authored
chore: CI bring back deploy on main (#4171)
This will deploy the latest main build to a dev environment. It first builds and pushes the image and then informs the internal argo workflow about the image tag and commit, in order to roll this out to dev. See also grafana/deployment_tools#256757
1 parent e788b9e commit 3ae47b4

File tree

3 files changed

+45
-51
lines changed

3 files changed

+45
-51
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches:
55
- main
6-
- r[0-9]+ # Trigger builds after a push to weekly branches
6+
77
pull_request:
88

99
permissions:
@@ -120,6 +120,10 @@ jobs:
120120
contents: read
121121
id-token: write
122122
runs-on: ubuntu-latest
123+
outputs:
124+
image: ${{ steps.push-metadata.outputs.image }}
125+
image-digest: ${{ steps.push-metadata.outputs.image-digest }}
126+
image-tag: ${{ steps.push-metadata.outputs.image-tag }}
123127
steps:
124128
- name: Checkout Repo
125129
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
@@ -149,3 +153,31 @@ jobs:
149153
id: build-push
150154
run: |
151155
make docker-image/pyroscope/push-multiarch "BUILDX_ARGS=--cache-from=type=gha --cache-to=type=gha"
156+
- name: Get image, image tag and image digest
157+
id: push-metadata
158+
run: |
159+
image=$(cat ./.docker-image-name-pyroscope)
160+
echo "image=${image}" >> "$GITHUB_OUTPUT"
161+
echo "image-tag=${image#*:}" >> "$GITHUB_OUTPUT"
162+
echo "image-digest=$(cat ./.docker-image-digest-pyroscope)" >> "$GITHUB_OUTPUT"
163+
164+
deploy-dev:
165+
permissions:
166+
contents: read
167+
id-token: write
168+
if: github.event_name == 'push' && github.repository == 'grafana/pyroscope' && github.ref == 'refs/heads/main'
169+
runs-on: ubuntu-latest
170+
needs: [build-push]
171+
steps:
172+
- id: "submit-argowfs-deployment"
173+
name: "Submit Argo Workflows deployment"
174+
uses: grafana/shared-workflows/actions/trigger-argo-workflow@af9b0c52635d39023136fb9312a354f91d9b2bfd
175+
with:
176+
namespace: "phlare-cd"
177+
workflow_template: "deploy-pyroscope-dev"
178+
parameters: |
179+
dockertag=${{ needs.build-push.outputs.image-tag }}
180+
commit=${{ github.sha }}
181+
- name: Print URI
182+
run: |
183+
echo "URI: ${{ steps.submit-argowfs-deployment.outputs.uri }}"

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ node_modules
3838
.pnp.*
3939
yarn-error.log
4040

41-
# Contains the docker image id for pyroscope
42-
/.docker-image-id-pyroscope
41+
# Contains the docker image digest for pyroscope
42+
/.docker-image-digest-pyroscope
43+
# Contains the docker image digest for frontend
44+
/.docker-image-digest-frontend
45+
# Contains the docker image name for pyroscope
46+
/.docker-image-name-pyroscope
4347

4448
/.tmp
4549
tools/k6/.env

Makefile

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ frontend/build:
107107

108108
.PHONY: frontend/shell
109109
frontend/shell:
110-
docker build -f cmd/pyroscope/frontend.Dockerfile --iidfile .docker-image-id-frontend --target builder .
111-
docker run -t -i $$(cat .docker-image-id-frontend) /bin/bash
110+
docker build -f cmd/pyroscope/frontend.Dockerfile --iidfile .docker-image-digest-frontend --target builder .
111+
docker run -t -i $$(cat .docker-image-digest-frontend) /bin/bash
112112

113113
.PHONY: profilecli/build
114114
profilecli/build: go/bin-profilecli ## Build the profilecli binary
@@ -224,7 +224,7 @@ define deploy
224224
$(BIN)/helm upgrade --install $(1) ./operations/pyroscope/helm/pyroscope $(2) $(HELM_ARGS) \
225225
--set pyroscope.image.tag=$(IMAGE_TAG) \
226226
--set pyroscope.image.repository=$(IMAGE_PREFIX)pyroscope \
227-
--set pyroscope.podAnnotations.image-id=$(shell cat .docker-image-id-pyroscope) \
227+
--set pyroscope.podAnnotations.image-digest=$(shell cat .docker-image-digest-pyroscope) \
228228
--set pyroscope.service.port_name=http-metrics \
229229
--set pyroscope.podAnnotations."profiles\.grafana\.com\/memory\.port_name"=http-metrics \
230230
--set pyroscope.podAnnotations."profiles\.grafana\.com\/cpu\.port_name"=http-metrics \
@@ -249,6 +249,8 @@ define multiarch_build
249249
GOOS=linux GOARCH=amd64 IMAGE_TAG="$(IMAGE_TAG)-amd64" $(MAKE) $(build_cmd) IMAGE_PLATFORM=linux/amd64
250250

251251
$(if $(push_image), docker buildx imagetools create --tag "$(image_name)" "$(image_name)-amd64" "$(image_name)-arm64")
252+
$(if $(push_image), docker buildx imagetools inspect "$(image_name)" --format "{{json .Manifest.Digest}}" | tr -d '"' > .docker-image-digest-pyroscope)
253+
$(if $(push_image), echo "$(image_name)" > .docker-image-name-pyroscope)
252254
endef
253255

254256
.PHONY: docker-image/pyroscope/build-multiarch
@@ -277,7 +279,7 @@ docker-image/pyroscope/push-debug: frontend/build go/bin-debug docker-image/pyro
277279

278280
.PHONY: docker-image/pyroscope/build
279281
docker-image/pyroscope/build: frontend/build go/bin
280-
$(call docker_buildx,--load --iidfile .docker-image-id-pyroscope,)
282+
$(call docker_buildx,--load --iidfile .docker-image-digest-pyroscope,)
281283

282284
.PHONY: docker-image/pyroscope/push
283285
docker-image/pyroscope/push: frontend/build go/bin
@@ -291,46 +293,6 @@ docker-image/pyroscope/dlv:
291293
GOPATH=$(CURDIR)/.tmp GOAMD64=v2 CGO_ENABLED=0 $(GO) install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/[email protected]
292294
mv $(CURDIR)/.tmp/bin/$(GOOS)_$(GOARCH)/dlv $(CURDIR)/.tmp/bin/dlv
293295

294-
define UPDATER_CONFIG_JSON
295-
{
296-
"git_author_name": "grafana-pyroscope-bot[bot]",
297-
"git_author_email": "140177480+grafana-pyroscope-bot[bot]@users.noreply.github.com",
298-
"git_committer_name": "grafana-pyroscope-bot[bot]",
299-
"git_committer_email": "140177480+grafana-pyroscope-bot[bot]@users.noreply.github.com",
300-
"pull_request_enabled": true,
301-
"pull_request_branch_prefix": "auto-merge/grafana-pyroscope-bot",
302-
"repo_name": "deployment_tools",
303-
"destination_branch": "master",
304-
"update_jsonnet_attribute_configs": [
305-
{
306-
"file_path": "ksonnet/lib/pyroscope/releases/dev/images.libsonnet",
307-
"jsonnet_key": "pyroscope",
308-
"jsonnet_value": "$(IMAGE_PREFIX)pyroscope:$(IMAGE_TAG)"
309-
}
310-
],
311-
"update_jsonnet_lib_configs": [
312-
{
313-
"jsonnet_dir": "ksonnet/lib/pyroscope/releases/dev",
314-
"dependencies": [
315-
{
316-
"owner": "grafana",
317-
"name": "pyroscope",
318-
"version": "$(GIT_REVISION)",
319-
"sub_dirs": [
320-
"operations/pyroscope"
321-
]
322-
}
323-
]
324-
}
325-
]
326-
}
327-
endef
328-
329-
.PHONY: docker-image/pyroscope/deploy-dev-001
330-
docker-image/pyroscope/deploy-dev-001: export CONFIG_JSON:=$(call UPDATER_CONFIG_JSON)
331-
docker-image/pyroscope/deploy-dev-001: $(BIN)/updater $(BIN)/jb
332-
PATH=$(BIN):$(PATH) $(BIN)/updater
333-
334296
.PHONY: clean
335297
clean: ## Delete intermediate build artifacts
336298
@# -X only removes untracked files, -d recurses into directories, -f actually removes files/dirs
@@ -406,10 +368,6 @@ $(BIN)/mockery: Makefile go.mod
406368
@mkdir -p $(@D)
407369
GOBIN=$(abspath $(@D)) $(GO) install github.com/vektra/mockery/[email protected]
408370

409-
$(BIN)/updater: Makefile
410-
@mkdir -p $(@D)
411-
GOBIN=$(abspath $(@D)) GOPRIVATE=github.com/grafana/deployment_tools $(GO) install github.com/grafana/deployment_tools/docker/updater/cmd/updater@bd5794b4e488
412-
413371
# Note: When updating the goreleaser version also update .github/workflow/release.yml and .git/workflow/weekly-release.yaml
414372
$(BIN)/goreleaser: Makefile go.mod
415373
@mkdir -p $(@D)

0 commit comments

Comments
 (0)