-
Notifications
You must be signed in to change notification settings - Fork 10
108 lines (93 loc) · 4.2 KB
/
images.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
name: Build and Push Images
on:
workflow_call:
release:
types: [published]
jobs:
docker-hub:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
# Only console released tag is starting with v, others are starting with @
if: ${{ (github.ref == 'refs/heads/main') && startsWith(github.event.release.tag_name, 'v') }}
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
if: ${{ (github.ref == 'refs/heads/main') && startsWith(github.event.release.tag_name, 'v') }}
uses: docker/login-action@v1
with:
username: dropletbot
password: ${{ secrets.botDockerHubPassword }}
- name: Build and push (latest)
if: ${{ (github.ref == 'refs/heads/main') && startsWith(github.event.release.tag_name, 'v') }}
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: instill/console:latest
cache-from: type=registry,ref=instill/console:buildcache
cache-to: type=registry,ref=instill/console:buildcache,mode=max
- name: Set Versions
if: github.event_name == 'release' && ${{ startsWith(github.event.release.tag_name, 'v') }}
uses: actions/github-script@v6
id: set_version
with:
script: |
const tag = '${{ github.event.release.tag_name }}'
const no_v_tag = tag.replace('v', '')
core.setOutput('tag', tag)
core.setOutput('no_v_tag', no_v_tag)
- name: Checkout
if: ${{ (github.event_name == 'release') && startsWith(github.event.release.tag_name, 'v') }}
uses: actions/checkout@v3
- name: Setup node
if: ${{ (github.event_name == 'release') && startsWith(github.event.release.tag_name, 'v') }}
uses: actions/setup-node@v3
with:
node-version: 20
- uses: pnpm/[email protected]
if: ${{ (github.event_name == 'release') && startsWith(github.event.release.tag_name, 'v') }}
name: Install pnpm
id: pnpm-install
with:
version: 9
run_install: false
- name: Get pnpm store directory
if: ${{ (github.event_name == 'release') && startsWith(github.event.release.tag_name, 'v') }}
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
if: ${{ (github.event_name == 'release') && startsWith(github.event.release.tag_name, 'v') }}
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
if: ${{ (github.event_name == 'release') && startsWith(github.event.release.tag_name, 'v') }}
run: rm -rf node_modules && pnpm i --frozen-lockfile
- name: Download component icons
if: ${{ (github.event_name == 'release') && startsWith(github.event.release.tag_name, 'v') }}
run: GITHUB_TOKEN=${{ secrets.botGitHubToken }} pnpm download-component-icons
- name: Set up Docker Buildx
# Only console released tag is starting with v, others are starting with @
if: ${{ (github.event_name == 'release') && startsWith(github.event.release.tag_name, 'v') }}
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
if: ${{ (github.event_name == 'release') && startsWith(github.event.release.tag_name, 'v') }}
uses: docker/login-action@v1
with:
username: dropletbot
password: ${{ secrets.botDockerHubPassword }}
- name: Build and push (release)
if: ${{ (github.event_name == 'release') && startsWith(github.event.release.tag_name, 'v') }}
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: instill/console:${{steps.set_version.outputs.no_v_tag}}
cache-from: type=registry,ref=instill/console:buildcache
cache-to: type=registry,ref=instill/console:buildcache,mode=max