-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathaction.yml
155 lines (152 loc) · 5.45 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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: "Setup Docker on macOS"
description: "Setup Docker on macOS using Colima, Lima-VM, and Homebrew."
inputs:
lima:
description: "Lima version. Defaults to the latest version."
required: false
default: "latest"
colima:
description: "Colima version. Defaults to the latest version."
required: false
default: "latest"
colima-network-address:
description: "Starts Colima with a reachable network address (`--network-address`). Makes Colima startup slower."
required: false
default: "false"
colima-additional-options:
description: "Starts Colima with additional options. May break Colima startup."
required: false
outputs:
colima-version:
value: ${{ steps.colima-version.outputs.version }}
description: Version of Colima
docker-client-version:
value: ${{ steps.docker-client-version.outputs.version }}
description: Version of the Docker client
docker-compose-version:
value: ${{ steps.docker-compose-version.outputs.version }}
description: Version of Docker Compose
runs:
using: "composite"
steps:
- name: OS safety check
if: runner.os != 'macOS'
run: |
echo "Not a macOS runner, exiting."
exit 1
shell: bash
- name: ARM64 safety check
run: |
arch_name=$(uname -m)
if [ "$arch_name" = "arm64" ]
then
echo "Detected M-series processor runner without nested virtualization support, exiting."
exit 1
else
echo "Running on supported architecture: ${arch_name}"
fi
shell: bash
- name: Update Homebrew
run: |
echo "::group::Updating Homebrew"
brew update
echo "::endgroup::"
shell: bash
- name: Install Lima
env:
GH_TOKEN: ${{ github.token }}
INPUT_LIMA: ${{ inputs.lima }}
run: |
if [ $INPUT_LIMA == "latest" ]
then
LIMA_VERSION=$(gh release -R lima-vm/lima view --json tagName -q ".tagName")
else
LIMA_VERSION=$INPUT_LIMA
fi
echo "::group::Installing Lima version $LIMA_VERSION"
curl -fsSL "https://github.com/lima-vm/lima/releases/download/${LIMA_VERSION}/lima-${LIMA_VERSION:1}-$(uname -s)-$(uname -m).tar.gz" | tar Cxzvm /usr/local
echo "::endgroup::"
shell: bash
- name: Install Colima
env:
GH_TOKEN: ${{ github.token }}
INPUT_COLIMA: ${{ inputs.colima }}
run: |
if [ $INPUT_COLIMA == "latest" ]
then
COLIMA_VERSION=$(gh release -R abiosoft/colima view --json tagName -q ".tagName")
else
COLIMA_VERSION=$INPUT_COLIMA
fi
echo "::group::Installing Colima version $COLIMA_VERSION"
curl -LO https://github.com/abiosoft/colima/releases/download/${COLIMA_VERSION}/colima-$(uname)-$(uname -m)
# install in $PATH
install colima-$(uname)-$(uname -m) /usr/local/bin/colima
echo "::endgroup::"
shell: bash
- name: Workaround for Python conflicts in GHA Runners
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
HOMEBREW_NO_INSTALL_UPGRADE: "1"
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1"
run: |
brew unlink python@3 || true
brew uninstall --ignore-dependencies python@3 || true
brew install --overwrite --force python@3
shell: bash
- name: Install Docker client, and Docker Compose
env:
HOMEBREW_NO_AUTO_UPDATE: "1"
HOMEBREW_NO_INSTALL_UPGRADE: "1"
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: "1"
run: |
echo "::group::Installing Docker client and Docker Compose"
brew install docker docker-compose
echo "::endgroup::"
shell: bash
- name: Configure Docker Compose plugin
run: |
mkdir -p ~/.docker/cli-plugins
ln -sfn "$(brew --prefix)/opt/docker-compose/bin/docker-compose" ~/.docker/cli-plugins/docker-compose
shell: bash
- name: Start Colima
env:
COLIMA_ADDITIONAL_OPTIONS: ${{ inputs.colima-additional-options }}
COLIMA_NETWORK_ADDRESS: ${{ inputs.colima-network-address }}
run: |
CPU_COUNT=$(sysctl -n hw.ncpu)
MEMORY=$(sysctl hw.memsize | awk '{print $2/1024/1024/1024}')
COLIMA_ARGS="--cpu $CPU_COUNT --memory $MEMORY --arch x86_64 --vm-type=vz --mount-type=virtiofs"
if [ $COLIMA_NETWORK_ADDRESS == "true" ]
then
COLIMA_ARGS="$COLIMA_ARGS --network-address"
fi
if [ -n "$COLIMA_ADDITIONAL_OPTIONS" ]
then
COLIMA_ARGS="$COLIMA_ARGS $COLIMA_ADDITIONAL_OPTIONS"
fi
echo "::group::Starting Colima with args: $COLIMA_ARGS"
colima start $COLIMA_ARGS
echo "::endgroup::"
shell: bash
- id: docker-client-version
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "version<<$EOF" >> "$GITHUB_OUTPUT"
docker version >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
shell: bash
- id: docker-compose-version
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "version<<$EOF" >> "$GITHUB_OUTPUT"
docker compose version >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
shell: bash
- id: colima-version
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "version<<$EOF" >> "$GITHUB_OUTPUT"
colima version >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
shell: bash