forked from ndeloof/install-compose-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
63 lines (59 loc) · 2.47 KB
/
action.yml
File metadata and controls
63 lines (59 loc) · 2.47 KB
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
# https://help.github.com/en/articles/metadata-syntax-for-github-actions
name: Docker Compose Setup
description: Install Docker Compose
branding:
icon: anchor
color: blue
inputs:
version:
description: 'Compose release (example: v2.2.0)'
required: false
default: v2.40.0
legacy:
description: 'Also install as legacy "docker-compose"'
required: false
default: true
artifact-url:
description: 'Direct URL to docker-compose artifact (zip file)'
required: false
default: ''
runs:
using: 'composite'
steps:
- name: instal
shell: bash
run: |
set -x
set -e
arch="$(uname)-$(uname -m)"
flavor=$(echo $arch | tr '[:upper:]' '[:lower:]' )
if [[ -n "${{ inputs.artifact-url }}" ]]; then
DOWNLOAD_URL="${{ inputs.artifact-url }}"
echo "Download Compose from artifact URL: ${DOWNLOAD_URL}"
mkdir -p ~/.docker/cli-plugins/
if [[ "$DOWNLOAD_URL" == *.zip ]]; then
curl -fsSL "$DOWNLOAD_URL" -o /tmp/compose-artifact.zip
unzip -o /tmp/compose-artifact.zip -d /tmp/
find /tmp -name "docker-compose-linux-*" -type f ! -name "*.json" -exec mv {} ~/.docker/cli-plugins/docker-compose \; 2>/dev/null || \
find /tmp -name "compose-linux-*" -type f ! -name "*.json" -exec mv {} ~/.docker/cli-plugins/docker-compose \;
rm -f /tmp/compose-artifact.zip
else
curl -fsSL "$DOWNLOAD_URL" -o ~/.docker/cli-plugins/docker-compose
fi
else
DOWNLOAD_URL="https://github.com/docker/compose/releases/download/${{ inputs.version }}/docker-compose-${flavor}"
if [[ "${{ inputs.version }}" == "latest" ]]; then
DOWNLOAD_URL=$(curl -fL https://api.github.com/repos/docker/compose/releases/latest | jq -r '.assets[] | select(.name == "docker-compose-linux-x86_64") | .browser_download_url')
fi
echo "Download Compose ${{ inputs.version }} for ${flavor} from ${DOWNLOAD_URL}"
mkdir -p ~/.docker/cli-plugins/
test -f ~/.docker/cli-plugins/docker-compose || curl -fsSL "$DOWNLOAD_URL" -o ~/.docker/cli-plugins/docker-compose
fi
chmod +x ~/.docker/cli-plugins/docker-compose
- name: alias docker-compose
if: ${{ inputs.legacy }}
shell: bash
run: |
mkdir -p ~/.local/bin/
ln -fs ~/.docker/cli-plugins/docker-compose ~/.local/bin/docker-compose
echo "${HOME}/.local/bin" >> $GITHUB_PATH