-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
96 lines (87 loc) · 3.73 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
name: "Image cache set-up"
description: "Configures the conan cache"
inputs:
faasm-version:
description: "Faasm version"
required: true
faabric-version:
description: "Faabric version"
required: true
read-only:
description: "Flag to indicate we are only ever reading from the cache"
required: false
default: 'false'
defaults:
run:
shell: bash
# This action is used to only pull all the images in a Faasm deployment
# once per GHA workflow. To do so, it is first called on its own, and
# follows (potentially) the write path where images are pulled and
# saved to a temporary directory (using docker save). Then, it is called
# in the "read" path, where images are loaded from the temporary directory.
runs:
using: "composite"
steps:
# First check if the cache is there already, as we can skip the next step
- uses: actions/cache/restore@v4
id: docker-image-cache-probe
with:
path: /tmp/faasm-docker-images.tar.gz
key: docker-image-cache-single-file-${{ inputs.faasm-version }}
lookup-only: true
# Make more space if we will fetch all images (so cache miss), or we will
# read (load) images (i.e. read-only mode)
- name: "Maximize build space"
uses: easimon/maximize-build-space@master
if: ${{ (steps.docker-image-cache-probe.outputs.cache-hit != 'true') || (inputs.read-only != 'false') }}
with:
# Leave 35 GB for the / partition for docker images (stored under
# /var/lib/docker)
root-reserve-mb: 38600
remove-android: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
remove-dotnet: 'true'
remove-haskell: 'true'
# Only call the cache action if:
# 1. We have a cache miss (so we always want to populate it)
# 2. We have a cache hit, and we are reading the cache
- uses: actions/cache@v4
if: ${{ (steps.docker-image-cache-probe.outputs.cache-hit != 'true') || (inputs.read-only != 'false') }}
id: docker-image-cache
with:
path: /tmp/faasm-docker-images.tar.gz
key: docker-image-cache-single-file-${{ inputs.faasm-version }}
# ----- Write Path -----
# Only pull the docker images when we have a cache miss
- name: "Pull all docker images"
if: ${{ steps.docker-image-cache-probe.outputs.cache-hit != 'true' }}
shell: bash
run: |
for image in redis minio upload cli # worker
do
docker image pull faasm.azurecr.io/${image}:${{ inputs.faasm-version }}
done
# docker image pull faasm.azurecr.io/planner:${{ inputs.faabric-version }}
# Save all docker images to one file when we have a cache miss, and we are not in read-only
- name: "Save them to a tar gzip file"
if: ${{ (steps.docker-image-cache-probe.outputs.cache-hit != 'true') && (inputs.read-only == 'false') }}
shell: bash
run: |
# faasm.azurecr.io/worker:${{ inputs.faasm-version}} \
# faasm.azurecr.io/planner:${{ inputs.faabric-version}} \
# faasm.azurecr.io/worker:${{ inputs.faasm-version}} \
docker image save \
faasm.azurecr.io/redis:${{ inputs.faasm-version}} \
faasm.azurecr.io/minio:${{ inputs.faasm-version}} \
faasm.azurecr.io/upload:${{ inputs.faasm-version}} \
faasm.azurecr.io/cli:${{ inputs.faasm-version}} | pigz --fast > /tmp/faasm-docker-images.tar.gz
ls -lart /tmp
# ----- Read Path -----
- name: "Load all images from the temporary directory"
# Load images when we are in read-only mode (previous steps should
# guarantee that the input file is there, fail otherwise)
if: ${{ inputs.read-only == 'true' }}
shell: bash
run: |
docker load --input /tmp/faasm-docker-images.tar.gz