-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
79 lines (65 loc) · 2.61 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
name: 'PHP Composer'
description: 'Use the Composer CLI in your Github Actions.'
inputs:
composer_version:
description: "What version of Composer to use"
default: latest
required: false
command:
description: "Composer command to run (or get_config to just get the output vars)"
required: true
default: install
args:
description: "Command line arguments to composer"
required: false
default: "--optimize-autoloader --no-progress"
github_oauth:
description: "OAuth token for accessing github private resources"
required: false
default: ""
outputs:
composer_cache_dir:
description: "Where composer created its cache"
value: ${{ steps.composer_run.outputs.composer_cache_dir }}
composer_major_version:
description: "Major version of the composer run (can be used as part of the cache key)"
value: ${{ steps.composer_run.outputs.composer_major_version }}
composer_version:
description: "Exact version of the composer run"
value: ${{ steps.composer_run.outputs.composer_major_version }}
runs:
using: "composite"
steps:
- env:
COMPOSER_VERSION: ${{ inputs.composer_version }}
COMPOSER_COMMAND: ${{ inputs.command }}
COMPOSER_ARGS: ${{ inputs.args }}
GITHUB_OAUTH: ${{ inputs.github_oauth }}
shell: bash
id: composer_run
run: |
set -e
# Make sure the latest version is available, pull it quietly
docker pull -q composer:${COMPOSER_VERSION}
# Extract the major version
DETECTED_VERSION=$(docker run --rm composer:${COMPOSER_VERSION} --version | perl -pe '($_)=/\b(\d+.\d+\.\d+)\b/;')
DETECTED_MAJOR_VERSION=$(docker run --rm composer:${COMPOSER_VERSION} --version | perl -pe '($_)=/\b(\d)\d*\.\d+\.\d+/;')
echo "::set-output name=composer_cache_dir::${RUNNER_WORKSPACE}/composer/cache"
echo "::set-output name=composer_major_version::${DETECTED_MAJOR_VERSION}"
echo "::set-output name=composer_version::${DETECTED_VERSION}"
COMPOSER_DOCKER="docker run --rm --user 1001 --volume ${RUNNER_WORKSPACE}/composer:/tmp --volume ${GITHUB_WORKSPACE}:/app -w /app composer:${COMPOSER_VERSION}"
if [ "$GITHUB_OAUTH" ]; then
$COMPOSER_DOCKER config -g github-oauth.github.com $GITHUB_OAUTH
fi
case "${COMPOSER_COMMAND}" in
get_config)
exit
;;
*)
echo "Running composer v${DETECTED_VERSION} with: $COMPOSER_COMMAND $COMPOSER_ARGS"
$COMPOSER_DOCKER $COMPOSER_COMMAND $COMPOSER_ARGS
;;
esac
branding:
icon: 'package'
color: 'purple'