Skip to content

Commit 9d6db7e

Browse files
authored
chore: GCP build and push workflow (lightdash#13426)
* chore: GCP build and push workflow * chore: amend secret name
1 parent d9319e6 commit 9d6db7e

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

Diff for: .github/workflows/gcp-build-and-push.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: GCP build and push
2+
on:
3+
workflow_dispatch
4+
5+
jobs:
6+
release:
7+
runs-on: lightdash-large-runner
8+
concurrency: ${{ github.ref }}
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
token: ${{ secrets.CI_GITHUB_TOKEN }}
13+
persist-credentials: false
14+
15+
- id: 'auth'
16+
uses: 'google-github-actions/auth@v2'
17+
with:
18+
credentials_json: '${{ secrets.GCP_CREDENTIALS_IMAGE_DEPLOY }}'
19+
20+
- name: 'Set up Cloud SDK'
21+
uses: 'google-github-actions/setup-gcloud@v2'
22+
with:
23+
version: '>= 381.0.0'
24+
25+
- name: 'Use gcloud CLI'
26+
run: 'gcloud info'
27+
28+
- name: Build and push
29+
run: bash ./scripts/gcp-build-and-push.sh

Diff for: .github/workflows/release-on-merge.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ jobs:
5959
-d '{"ref": "main", "inputs": {"lightdash-version": "${{ steps.semantic.outputs.new_release_version }}"}}' \
6060
https://api.github.com/repos/lightdash/helm-charts/action/workflows/increment-lightdash-app-version.yml/dispatches
6161
- name: Trigger Sentry release
62-
if: steps.package-version.outputs.current-version != ''
62+
if: steps.semantic.outputs.new_release_published == 'true' &&
63+
steps.semantic.outputs.new_release_channel == null
6364
env:
6465
GH_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
6566
run: |
@@ -68,4 +69,15 @@ jobs:
6869
-H "X-GitHub-Api-Version: 2022-11-28" \
6970
/repos/lightdash/lightdash/actions/workflows/create-sentry-release.yml/dispatches \
7071
-f "ref=main" \
71-
-f "inputs[version]=${{ steps.package-version.outputs.current-version }}"
72+
-f "inputs[version]=${{ steps.semantic.outputs.new_release_version }}"
73+
- name: Trigger GCP build and push
74+
if: steps.semantic.outputs.new_release_published == 'true' &&
75+
steps.semantic.outputs.new_release_channel == null
76+
env:
77+
GH_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
78+
run: |
79+
gh api --method POST \
80+
-H "Accept: application/vnd.github+json" \
81+
-H "X-GitHub-Api-Version: 2022-11-28" \
82+
/repos/lightdash/lightdash/actions/workflows/gcp-build-and-push.yml/dispatches \
83+
-f "ref=main"

Diff for: scripts/gcp-build-and-push.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if ! command -v jq &> /dev/null
6+
then
7+
echo "Command 'jq' could not be found, install it with 'brew install jq' or an equivalent command"
8+
exit 1
9+
fi
10+
11+
version=$(cat package.json | jq -r '.version')
12+
echo "fork version: $version"
13+
timestamp=$(date +%Y.%m.%d-%H.%M.%S)
14+
image="us-east4-docker.pkg.dev/lightdash-cloud-beta/lightdash-commercial/lightdash-commercial"
15+
16+
echo "Building with tags: $version-commercial, beta, $timestamp"
17+
18+
gcloud auth configure-docker us-east4-docker.pkg.dev
19+
20+
docker build . -t "$image:beta" -t "$image:$timestamp" -t "$image:$version-commercial"
21+
22+
for tag in "$version-commercial" "beta" "$timestamp"; do
23+
docker push "$image:$tag"
24+
done
25+
26+
# Delete images to avoid filling up disk space
27+
for tag in "$version-commercial" "beta" "$timestamp"; do
28+
docker image rm "$image:$tag"
29+
done

0 commit comments

Comments
 (0)