Skip to content

Commit d0a80b2

Browse files
author
Greg Bowler
committed
Switch composer version
1 parent e4b6665 commit d0a80b2

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
FROM composer:1.10.15
1+
FROM ghcr.io/php-actions/php-build:latest
22

33
LABEL repository="https://github.com/php-actions/composer"
44
LABEL homepage="https://github.com/php-actions/composer"
55
LABEL maintainer="Greg Bowler <[email protected]>"
66

7+
RUN curl https://getcomposer.org/download/1.10.17/composer.phar > composer-1.phar
8+
RUN curl https://getcomposer.org/download/2.0.6/composer.phar > composer-2.phar
9+
RUN chmod +x *.phar
10+
RUN ln -s $(pwd)/composer-1.phar /usr/local/bin/composer-1
11+
RUN ln -s $(pwd)/composer-2.phar /usr/local/bin/composer-2
12+
RUN ln -s /usr/local/bin/composer-2 /usr/local/bin/composer
13+
COPY switch-composer-version /usr/local/bin/.
14+
715
COPY entrypoint /usr/local/bin/entrypoint
816
ENTRYPOINT ["/usr/local/bin/entrypoint"]
917
CMD ["help"]

action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
name: 'Composer (php-actions)'
22
description: 'Use the Composer CLI in your Github Actions.'
33
inputs:
4+
php_version:
5+
description: What version of PHP to use
6+
default: latest
7+
required: false
8+
9+
composer_version:
10+
description: What version of Composer to use
11+
default: latest
12+
required: false
13+
414
command:
515
description: Composer command to run
616
required: true

entrypoint

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
#!/bin/bash
22
set -e
33

4+
if [ -n "$action_php_version" ]
5+
then
6+
echo "Using PHP version: $action_php_version"
7+
switch-php-version $action_php_version
8+
fi
9+
10+
if [ -n "$action_composer_version" ]
11+
then
12+
echo "Using Composer version: $action_composer_version"
13+
switch-composer-version $action_composer_version
14+
fi
15+
416
command_string="composer"
517

618
if [ -n "$action_ssh_key" ]

switch-composer-version

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ "$1" = "latest" ]
5+
then
6+
version=2
7+
else
8+
version=$1
9+
fi
10+
11+
composer_bin="/usr/local/bin/composer-$version"
12+
13+
if test -f $composer_bin
14+
then
15+
rm -f /usr/local/bin/composer
16+
ln -s "$composer_bin" "/usr/local/bin/composer"
17+
echo "Successfully linked $composer_bin"
18+
else
19+
echo "Error linking $composer_bin: version doesn't exit"
20+
exit 1
21+
fi

0 commit comments

Comments
 (0)