forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 5
84 lines (72 loc) · 2.79 KB
/
Copy pathdeploy-cloud-run-grafana.yaml
File metadata and controls
84 lines (72 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Deploy Grafana Server Cloud Run on Dev
on:
push:
branches:
- '**'
paths:
- "/**"
workflow_dispatch:
jobs:
build_and_deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
env:
DEV4_IMAGE: gcr.io/coderabbitdev4/grafana-base:latest
DEV4_WIF_PROVIDER: "projects/803057949155/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider"
DEV4_WIF_SERVICE_ACCOUNT: "gha-dev4-sa@coderabbitdev4.iam.gserviceaccount.com"
steps:
- uses: actions/checkout@v4
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
sudo docker system prune -af || true
df -h
- uses: docker/setup-buildx-action@v3
# - name: Cache Docker layers
# uses: actions/cache@v4
# with:
# path: /tmp/.buildx-cache
# key: ${{ runner.os }}-${{ github.workflow }}-${{ github.sha }}
# restore-keys: ${{ runner.os }}-${{ github.workflow }}-
- name: Build image once
uses: docker/build-push-action@v5
with:
context: .
push: false
load: true
tags: grafana:latest
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Authenticate to Google Cloud (dev4) with OIDC
id: auth_dev4
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ env.DEV4_WIF_PROVIDER }}
service_account: ${{ env.DEV4_WIF_SERVICE_ACCOUNT }}
token_format: access_token
- name: Login to GCR (dev4)
uses: docker/login-action@v3
with:
registry: gcr.io
username: oauth2accesstoken
password: ${{ steps.auth_dev4.outputs.access_token }}
- name: Push image to dev4
run: |
docker tag grafana:latest "$DEV4_IMAGE"
docker push "$DEV4_IMAGE"
# - name: Move Docker cache
# run: |
# rm -rf /tmp/.buildx-cache
# mv /tmp/.buildx-cache-new /tmp/.buildx-cache
# - name: Deploy to Cloud Run
# run: gcloud run deploy grafana --image gcr.io/coderabbit/grafana:latest --region us-central1 --allow-unauthenticated --vpc-connector=coderabbitai-dev-cr
- name: Trigger a repository dispatch
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.PAT_TRIGGER_GRAFANA }}" \
-H "Accept: application/vnd.github.everest-preview+json" \
https://api.github.com/repos/coderabbitai/mono/dispatches \
-d "{\"event_type\": \"trigger-grafana-micro-frontend-dev\", \"client_payload\": {\"ref\": \"${GITHUB_REF}\"}}"