-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
action.yml
140 lines (140 loc) · 5.17 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
name: 'Spin-Up Docker Compose'
author: yu-ichiro
description: 'An action to spin up docker compose environment within GitHub Actions.'
branding:
icon: box
color: blue
inputs:
file:
description: 'the file to parse targets from, normally compose.yml. supported extensions: yml, json'
type: string
required: true
cache-key:
description: 'the cache key to use for saving build data. defaults to "default"'
type: string
required: false
default: 'default'
shared:
description: 'whether to use local registry to share built images. this enables `registry` and `localhost`. defaults to false'
type: boolean
required: false
default: false
registry:
description: 'whether to use a local registry or not. defaults to false'
type: boolean
required: false
default: false
localhost:
description: 'whether to replace targets registry to localhost or not. registry must be true to use this. defaults to false'
type: boolean
required: false
default: false
pull:
description: 'whether to pull targets images. defaults to false'
type: boolean
required: false
default: false
pull-opts:
description: 'options to pass to docker compose pull. pull must be true to use this. defaults to ""'
type: string
required: false
default: ""
bake:
description: 'whether to bake targets. defaults to false'
type: boolean
required: false
default: false
push:
description: 'whether to push targets images after baking. bake must be true to use this. defaults to false'
type: boolean
required: false
default: false
bake-opts:
description: 'options to pass to docker buildx bake. bake must be true to use this. defaults to ""'
type: string
required: false
default: ""
up:
description: 'whether to boot up docker compose. defaults to true'
type: boolean
required: false
default: true
up-opts:
description: 'options to pass to docker compose up. up must be true to use this. defaults to "-d"'
type: string
required: false
default: "-d"
buildx-version:
description: 'the version of buildx to use. see docker/setup-buildx-action for details'
type: string
required: false
default: "latest"
dry-run:
description: '[debugging] dry-run the action'
required: false
default: false
runs:
using: "composite"
steps:
- if: fromJson(inputs.bake)
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ inputs.cache-key }}-buildx-cache-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ inputs.cache-key }}-buildx-cache-${{ github.ref }}
${{ inputs.cache-key }}-buildx-cache-
- if: fromJson(inputs.bake)
id: buildx
uses: docker/setup-buildx-action@v1
with:
version: ${{ inputs.buildx-version }}
driver-opts: network=host
- if: fromJson(inputs.registry) || fromJson(inputs.shared)
uses: actions/cache@v3
with:
path: /tmp/docker-registry
key: ${{ inputs.cache-key }}-docker-registry-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ inputs.cache-key }}-docker-registry-${{ github.ref }}
${{ inputs.cache-key }}-docker-registry-
- if: fromJson(inputs.registry) || fromJson(inputs.shared)
shell: bash
run: |
[ "${{ inputs.dry-run }}" = "true" ]&&prefix="echo"; \
$prefix docker run -d -p 5000:5000 --restart=always --name registry -v /tmp/docker-registry:/var/lib/registry registry:2; \
$prefix npx wait-on tcp:5000
- if: fromJson(inputs.bake) || fromJson(inputs.localhost) || fromJson(inputs.shared)
shell: bash
run: |
[ "${{ inputs.dry-run }}" = "true" ]&&prefix="echo"; \
$prefix pip install -r ${{ github.action_path }}/requirements.txt
- if: (fromJson(inputs.registry) && fromJson(inputs.localhost)) || fromJson(inputs.shared)
shell: bash
run: |
[ "${{ inputs.dry-run }}" = "true" ]&&prefix="echo"; \
$prefix python ${{ github.action_path }}/convert.py localhost ${{ inputs.file }}
- if: fromJson(inputs.pull)
shell: bash
run: |
[ "${{ inputs.dry-run }}" = "true" ]&&prefix="echo"; \
$prefix docker compose -f "${{ inputs.file }}" pull ${{ inputs.pull-opts }}
- if: fromJson(inputs.bake)
shell: bash
run: |
[ "${{ inputs.dry-run }}" = "true" ]&&prefix="echo"; \
[ "${{ inputs.push }}" = "true" ]&&action="--push"||action="--load"; \
$prefix python ${{ github.action_path }}/convert.py add_image_tag ${{ inputs.file }}; \
$prefix cd $(dirname ${{ inputs.file }}); \
$prefix docker buildx bake \
--builder="${{ steps.buildx.outputs.name }}" \
--set='*.cache-from=type=local,src=/tmp/.buildx-cache' \
--set='*.cache-to=type=local,dest=/tmp/.buildx-cache' \
$action \
-f "$(basename ${{ inputs.file }})" ${{ inputs.bake-opts }}; \
$prefix docker image ls
- if: fromJson(inputs.up)
shell: bash
run: |
[ "${{ inputs.dry-run }}" = "true" ]&&prefix="echo"; \
$prefix docker compose -f "${{ inputs.file }}" up ${{ inputs.up-opts }}