-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
115 lines (99 loc) · 3.18 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
name: 'Install composer dependencies'
description: 'Set up PHP and install composer dependencies'
inputs:
command:
description: 'The composer command to run.'
required: false
default: 'install'
php-version:
description: 'The php version to use.'
default: '7.2'
required: false
composer-args:
description: 'Arguments to pass to Composer. Should be a multiline string.'
required: false
# Deprecated, use composer-args
# TODO: Remove in v5
flags:
description: 'Flags to use when installing composer dependencies.'
required: false
outputs:
image:
description: 'The image name that was used to install dependencies. Can be used in subsequent jobs.'
value: ${{ steps.prepare.outputs.image }}
env-file:
description: 'The filename of the env file that was created.'
value: ${{ steps.env.outputs.filename }}
runs:
using: composite
steps:
- uses: myparcelnl/actions/deprecated@v4
if: inputs.flags != ''
with:
name: 'inputs.flags'
replacement: 'inputs.composer-args'
- name: 'Hash composer args'
id: args
uses: myparcelnl/actions/hash-string@v4
with:
string: ${{ inputs.composer-args || inputs.flags }}
- name: 'Prepare'
id: prepare
shell: bash
env:
VERSION: ${{ inputs.php-version }}
#language=bash
run: |
echo "image=ghcr.io/myparcelnl/php-xd:$VERSION" >> $GITHUB_OUTPUT
echo COMPOSER_CACHE_DIR=/tmp/cache/composer >> $GITHUB_ENV
- uses: myparcelnl/actions/create-cache-keys@v4
id: keys-composer
with:
key: 'composer'
restore-keys: 3
input: |
${{ inputs.php-version }}
${{ inputs.command }}
${{ steps.args.outputs.hash }}
${{ hashFiles('**/composer.json', '**/composer.lock') }}
- name: 'Handle composer cache'
uses: actions/cache@v4
env:
RUNNER_DEBUG: 0
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: ${{ steps.keys-composer.outputs.key }}
restore-keys: ${{ steps.keys-composer.outputs.restore-keys }}
- uses: myparcelnl/actions/pull-docker-image@v4
with:
image: ${{ steps.prepare.outputs.image }}
- uses: myparcelnl/actions/composer-create-env-file@v4
id: env
- uses: myparcelnl/actions/format-string@v4
id: composer-args
with:
mode: 'args'
string: |
--no-interaction
--no-plugins
--no-progress
--no-scripts
--optimize-autoloader
${{ runner.debug == '1' && '--verbose' || '' }}
${{ inputs.composer-args || inputs.flags }}
- name: 'Install composer dependencies'
shell: bash
env:
COMMAND: ${{ inputs.command }}
COMPOSER_ARGS: ${{ steps.composer-args.outputs.string }}
ENV_FILE: ${{ steps.env.outputs.filename }}
IMAGE: ${{ steps.prepare.outputs.image }}
#language=bash
run: |
docker run \
--volume "$PWD:/app" \
--volume "$COMPOSER_CACHE_DIR:$COMPOSER_CACHE_DIR" \
--user "$(id -u):$(id -g)" \
--env-file "$ENV_FILE" \
"$IMAGE" \
composer "$COMMAND" $COMPOSER_ARGS