-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
102 lines (97 loc) · 4.09 KB
/
action.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
name: Setup Supabase CLI
description: Installs the Supabase CLI and optionally configures caching for the required docker images
inputs:
version:
description: Release of Supabase CLI to install
required: true
architecture:
description: Architecture of the binary to download
required: false
default: amd64
image-registry:
description: Image registry which should be used for downloading the docker images. GitHub container registry is used per default for faster pulls in GH Action CI runs. Specify an empty string to use the CLI default of AWS ECR. Alternatively you can also specify "docker.io".
required: false
default: "ghcr.io"
enable-binary-cache:
description: Whether to use actions/cache for caching the supabase binary
required: false
default: "true"
enable-docker-cache:
description: Whether to use actions/cache for caching downloaded docker images
required: false
# Currently slower than just downloading all images every time...
default: "false"
runs:
using: composite
steps:
# CHECK EXISTING DOCKER IMAGES
- name: Capture existing docker images
if: inputs.enable-docker-cache == 'true'
shell: bash
working-directory: ${{ runner.temp }}
run: docker images --format="{{.Repository}}:{{.Tag}}" > existing-docker-containers.txt
# SETUP ENV VARIABLE
- name: Setting container registry to "${{ inputs.image-registry }}"
shell: bash
env:
REGISTRY: ${{ inputs.image-registry }}
run: echo "SUPABASE_INTERNAL_IMAGE_REGISTRY=$REGISTRY" >> $GITHUB_ENV
# SETUP SUPABASE BINARY
- name: Cache Supabase CLI binary
id: supabase-binary-cache
if: inputs.enable-binary-cache == 'true'
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/supabase-cli
key: supabase-binary-${{ inputs.architecture }}-${{ inputs.version }}
- name: Download Supabase CLI
if: inputs.enable-binary-cache != 'true' || steps.supabase-binary-cache.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ runner.temp }}
env:
VERSION: ${{ inputs.version }}
ARCH: ${{ inputs.architecture }}
run: |
mkdir supabase-cli
curl -L -o supabase-cli.tar.gz https://github.com/supabase/cli/releases/download/v${VERSION}/supabase_${VERSION}_linux_${ARCH}.tar.gz
tar -xzf supabase-cli.tar.gz -C supabase-cli
rm supabase-cli.tar.gz
- name: Install Supabase CLI
shell: bash
working-directory: ${{ runner.temp }}
run: |
echo "${PWD}/supabase-cli" >> $GITHUB_PATH
echo "Installed Supabase-CLI version:"
./supabase-cli/supabase --version
# DOCKER IMAGE CACHING
- name: Restore docker image cache
if: inputs.enable-docker-cache == 'true'
id: docker-images-cache
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/docker-images-cache
key: docker-images-${{ inputs.architecture }}-${{ inputs.version }}
- name: Create cache directory
if: inputs.enable-docker-cache == 'true' && steps.docker-images-cache.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ runner.temp }}
run: mkdir docker-images-cache
- name: Start docker registry
if: inputs.enable-docker-cache == 'true'
shell: bash
working-directory: ${{ runner.temp }}/docker-images-cache
run: |
mkdir -p registry
docker run -d -p 46318:5000 --restart=always --name registry -v "$PWD/registry:/var/lib/registry" registry:2
npx wait-on tcp:46318
- name: Import docker image cache
if: inputs.enable-docker-cache == 'true' && steps.docker-images-cache.outputs.cache-hit == 'true'
shell: bash
working-directory: ${{ runner.temp }}
run: ${{ github.action_path }}/import-docker-images.sh
- name: Export docker images for cache
if: inputs.enable-docker-cache == 'true' && steps.docker-images-cache.outputs.cache-hit != 'true'
uses: webiny/[email protected]
with:
working-directory: ${{ runner.temp }}
run: ${{ github.action_path }}/export-docker-images.sh