-
Notifications
You must be signed in to change notification settings - Fork 124
91 lines (78 loc) · 3.46 KB
/
rill-cloud.yml
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
85
86
87
88
89
90
91
# This workflow triggers deployment with Rill Cloud helm charts
# Each merge to main branch is build with github sha tag and published to Rill Cloud.
name: Deploy to Rill Cloud
on:
create:
push:
tags:
- "**"
branches:
- "main"
- "release**"
workflow_dispatch:
env:
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
DEPLOY_CLOUD: 1
jobs:
release:
# https://github.com/orgs/community/discussions/54860
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || ( github.event_name == 'create' && startsWith(github.ref_name, 'release') )
name: Deploy to Rill Cloud
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23
- name: Authenticate GCloud
uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.RILL_BINARY_SA }}"
- name: Set up GCloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Build & Publish Rill docker image
run: |-
if [ "$RELEASE" == "true" ] || [ "$GITHUB_REF_NAME" == "main" ]; then
echo "DEPLOY_CLOUD=1" >> $GITHUB_ENV
else
echo "DEPLOY_CLOUD=$(git branch -r | grep release-0 | sort | tail -1 | grep -c $GITHUB_REF_NAME)" >> $GITHUB_ENV
fi
if [ ${RELEASE} == "false" ]; then
echo "Fetch tags to get the last tagged version"
git fetch --all --tags;
fi
# Embed DuckDB extensions in the Rill binary
go run scripts/embed_duckdb_ext/main.go
if [ ${RELEASE} == "true" ]; then
go build -o rill -mod=readonly -ldflags="-s -w -X main.Version=$(git describe --tags `git rev-list --tags --max-count=1`) -X main.Commit=${GITHUB_SHA} -X main.BuildDate=$(date +%FT%T)" cli/main.go
else
go build -o rill -mod=readonly -ldflags="-s -w -X main.Commit=${GITHUB_SHA} -X main.BuildDate=$(date +%FT%T)" cli/main.go
fi
gcloud auth configure-docker
docker build -t gcr.io/rilldata/rill-headless:${GITHUB_SHA} .
docker push gcr.io/rilldata/rill-headless:${GITHUB_SHA}
if [ ${RELEASE} == "true" ]; then
docker tag gcr.io/rilldata/rill-headless:${GITHUB_SHA} gcr.io/rilldata/rill-headless:${GITHUB_REF_NAME}
docker push gcr.io/rilldata/rill-headless:${GITHUB_REF_NAME}
fi
- name: Trigger Rill Cloud deployment
if: env.DEPLOY_CLOUD == '1'
run: |-
set -e
curl -X POST https://api.github.com/repos/rilldata/rill-helm-charts/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ secrets.GORELEASER_ACCESS_TOKEN }}" \
--data '{"event_type": "Deploying Tag: '"${GITHUB_REF_NAME}"'", "client_payload": { "github_sha": "'"${GITHUB_SHA}"'", "tag": "'"${GITHUB_REF_NAME}"'", "release": "${{ env.RELEASE }}"}}'
- name: Notify Slack
uses: ravsamhq/notify-slack-action@v2
if: always()
with:
status: ${{ job.status }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
footer: "Linked Repo <{repo_url}|{repo}>"
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ANNOUNCE_DD }}