-
Notifications
You must be signed in to change notification settings - Fork 126
128 lines (119 loc) · 4.26 KB
/
release.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Release
on:
push:
tags:
- 'v*'
jobs:
download-uberjar:
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- name: Download Uberjar for ${{ github.ref_name }}
run: |
JAR_DOWNLOAD_URL=https://downloads.metabase.com/${{ github.ref_name }}/metabase.jar
if [[ ${{ github.ref_name }} == v1* ]]; then
JAR_DOWNLOAD_URL=https://downloads.metabase.com/enterprise/${{ github.ref_name }}/metabase.jar
fi
echo $JAR_DOWNLOAD_URL > url.txt
echo "----- Downloading Uberjar from $JAR_DOWNLOAD_URL -----"
curl -OL $JAR_DOWNLOAD_URL
stat ./metabase.jar
date | tee timestamp
- name: Calculate SHA256 checksum
run: sha256sum ./metabase.jar | tee SHA256.sum
- name: Upload Uberjar as artifact
uses: actions/upload-artifact@v2
with:
name: metabase-uberjar-${{ github.ref_name }}
path: |
./metabase.jar
./url.txt
./timestamp
./SHA256.sum
check-uberjar:
runs-on: ubuntu-20.04
needs: download-uberjar
timeout-minutes: 10
steps:
- name: Prepare JRE (Java Run-time Environment)
uses: actions/setup-java@v3
with:
java-package: jre
java-version: 11
distribution: 'temurin'
- uses: actions/download-artifact@v2
name: Retrieve previously downloaded Uberjar
with:
name: metabase-uberjar-${{ github.ref_name }}
- name: Reveal its version.properties
run: jar xf metabase.jar version.properties && cat version.properties
- name: Display when and where it was downloaded
run: |
cat timestamp
cat url.txt
- name: Show the checksum
run: cat SHA256.sum
- name: Launch Metabase Uberjar (and keep it running)
run: java -jar ./metabase.jar &
- name: Wait for Metabase to start
run: while ! curl -s localhost:3000/api/health; do sleep 1; done
timeout-minutes: 3
- name: Check API health
run: curl -s localhost:3000/api/health
containerize:
runs-on: ubuntu-20.04
needs: check-uberjar
timeout-minutes: 15
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v2
name: Retrieve previously downloaded Uberjar
with:
name: metabase-uberjar-${{ github.ref_name }}
- name: Move the Uberjar to the context dir
run: mv ./metabase.jar bin/docker/.
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Build ${{ matrix.edition }} container
uses: docker/build-push-action@v2
with:
context: bin/docker/.
platforms: linux/amd64
network: host
tags: localhost:5000/local-metabase:${{ github.ref_name }}
no-cache: true
push: true
- name: Launch container
run: docker run --rm -dp 3000:3000 localhost:5000/local-metabase:${{ github.ref_name }}
timeout-minutes: 5
- name: Wait for Metabase to start
run: while ! curl -s 'http://localhost:3000/api/health' | grep '{"status":"ok"}'; do sleep 1; done
timeout-minutes: 3
- name: Determine the target Docker Hub repository
run: |
if [[ ${{ github.ref_name }} == v1* ]]; then
echo "Metabase EE: image is going to be pushed to ${{ github.repository_owner }}/metabase-enterprise"
echo "DOCKERHUB_REPO=${{ github.repository_owner }}/metabase-enterprise" >> $GITHUB_ENV
else
echo "Metabase OSS: image is going to be pushed to ${{ github.repository_owner }}/metabase"
echo "DOCKERHUB_REPO=${{ github.repository_owner }}/metabase" >> $GITHUB_ENV
fi
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Retag and push container image to Docker Hub
run: |
echo "Pushing ${{ github.ref_name }} to ${{ env.DOCKERHUB_REPO }} ..."
docker tag localhost:5000/local-metabase:${{ github.ref_name }} ${{ env.DOCKERHUB_REPO }}:${{ github.ref_name }}
docker push ${{ env.DOCKERHUB_REPO }}:${{ github.ref_name }}
echo "Finished!"