Skip to content

Commit 4be952b

Browse files
authored
Refactor github actions (#4157)
- Pull secrets for docker hub from vault - Use github token for publishing release
1 parent 08f3796 commit 4be952b

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

.github/workflows/test.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ jobs:
116116

117117
build-push:
118118
if: github.event_name == 'push' && github.repository == 'grafana/pyroscope'
119+
permissions:
120+
contents: read
121+
id-token: write
119122
runs-on: ubuntu-latest
120123
steps:
121124
- name: Checkout Repo
@@ -130,11 +133,18 @@ jobs:
130133
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
131134
with:
132135
go-version: 1.23.8
133-
- name: Login to Docker Hub
134-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
136+
# login to docker hub
137+
- id: get-secrets
138+
uses: grafana/shared-workflows/actions/get-vault-secrets@28361cdb22223e5f1e34358c86c20908e7248760
135139
with:
136-
username: ${{ secrets.DOCKERHUB_USERNAME }}
137-
password: ${{ secrets.DOCKERHUB_TOKEN }}
140+
common_secrets: |
141+
DOCKERHUB_USERNAME=dockerhub:username
142+
DOCKERHUB_PASSWORD=dockerhub:password
143+
- uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2
144+
name: Login to Docker Hub
145+
with:
146+
username: ${{ env.DOCKERHUB_USERNAME }}
147+
password: ${{ env.DOCKERHUB_PASSWORD }}
138148
- name: Pyroscope Build & push multi-arch image
139149
id: build-push
140150
run: |

.github/workflows/weekly-release.yml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ on:
66
- 'weekly/f*'
77

88
permissions:
9-
contents: read
9+
contents: write
10+
actions: write
11+
id-token: write
1012

1113
jobs:
1214
goreleaser-weekly:
@@ -40,29 +42,28 @@ jobs:
4042
- name: Set up Docker Buildx
4143
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # v2
4244
# login to docker hub
45+
- id: get-secrets
46+
uses: grafana/shared-workflows/actions/get-vault-secrets@28361cdb22223e5f1e34358c86c20908e7248760
47+
with:
48+
common_secrets: |
49+
DOCKERHUB_USERNAME=dockerhub:username
50+
DOCKERHUB_PASSWORD=dockerhub:password
4351
- uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2
4452
name: Login to Docker Hub
4553
with:
46-
username: ${{ secrets.DOCKERHUB_USERNAME }}
47-
password: ${{ secrets.DOCKERHUB_TOKEN }}
54+
username: ${{ env.DOCKERHUB_USERNAME }}
55+
password: ${{ env.DOCKERHUB_PASSWORD }}
4856
- uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3
4957
with:
5058
node-version: 20
5159
- run: make frontend/build
52-
- name: Get github app token (valid for an hour)
53-
id: app-goreleaser
54-
uses: tibdex/github-app-token@32691ba7c9e7063bd457bd8f2a5703138591fa58 # v1
55-
with:
56-
app_id: ${{ secrets.APP_ID }}
57-
private_key: ${{ secrets.APP_PRIVATE_KEY }}
5860
- uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6
5961
with:
6062
# ensure this aligns with the version specified in the /Makefile
6163
version: v2.7.0
6264
args: release --clean --skip=publish --timeout 60m
6365
env:
64-
GITHUB_TOKEN: ${{ steps.app-releaser.outputs.token }}
65-
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6667
- name: Push per architecture images and create multi-arch manifest
6768
run: |
6869
set -eu -o pipefail
@@ -88,11 +89,5 @@ jobs:
8889
8990
docker manifest create "grafana/pyroscope:${WEEKLY_IMAGE_TAG}" "${IMAGE_AMMENDS[@]}"
9091
docker manifest push "grafana/pyroscope:${WEEKLY_IMAGE_TAG}"
91-
- name: Get github app token (valid for an hour)
92-
id: app-git-tag
93-
uses: tibdex/github-app-token@32691ba7c9e7063bd457bd8f2a5703138591fa58 # v1
94-
with:
95-
app_id: ${{ secrets.APP_ID }}
96-
private_key: ${{ secrets.APP_PRIVATE_KEY }}
9792
- name: Push git tag for weekly release
98-
run: git push "https://x-access-token:${{ steps.app-git-tag.output.token }}@github.com/grafana/pyroscope.git" "${WEEKLY_IMAGE_TAG}" 2> /dev/null
93+
run: git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/grafana/pyroscope.git" "${WEEKLY_IMAGE_TAG}" 2> /dev/null

0 commit comments

Comments
 (0)