-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 570ccbf
Showing
3 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Install PHIVE in GitHub Actions | ||
|
||
The Phar Installation and Verification Environment :) | ||
|
||
### Usage | ||
|
||
```yaml | ||
jobs: | ||
phive: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Install PHP tools with PHIVE" | ||
uses: "szepeviktor/phive@v1" | ||
``` | ||
Full example. | ||
```yaml | ||
jobs: | ||
phive: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-version: | ||
- "7.4" | ||
- "7.3" | ||
steps: | ||
- name: "Set default PHP version" | ||
run: "sudo update-alternatives --set php /usr/bin/php${{ matrix.php-version }}" | ||
- name: "Checkout code" | ||
uses: "actions/checkout@v2" | ||
- name: "Cache tools installed with PHIVE" | ||
uses: "actions/cache@v2.1.2" | ||
with: | ||
path: "$HOME/.phive" | ||
key: "php-${{ matrix.php-version }}-phive-${{ hashFiles('.phive/phars.xml') }}" | ||
restore-keys: "php-${{ matrix.php-version }}-phive-" | ||
|
||
- name: "Install PHIVE" | ||
uses: "szepeviktor/phive@v1" | ||
with: | ||
home: "$HOME/.phive" | ||
binPath: "${{ github.workspace }}/tools/phive" | ||
|
||
- name: "Install PHP tools with PHIVE" | ||
uses: "szepeviktor/phive-install@v1" | ||
with: | ||
home: "$HOME/.phive" | ||
binPath: "${{ github.workspace }}/tools/phive" | ||
trustGpgKeys: "4AA394086372C20A,CF1A108D0E7AE720,E82B2FB314E9906E" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: "Install PHIVE" | ||
|
||
description: "The Phar Installation and Verification Environment" | ||
|
||
branding: | ||
color: "purple" | ||
icon: "anchor" | ||
|
||
inputs: | ||
home: | ||
description: "Home path of PHIVE" | ||
required: false | ||
default: "$HOME/.phive" | ||
binPath: | ||
description: "Path of the PHIVE binary" | ||
required: false | ||
default: "${{ github.workspace }}/tools/phive" | ||
signingKey: | ||
description: "PHIVE release GPG key hash" | ||
required: false | ||
default: "0x9D8A98B29B2D5D79" | ||
|
||
runs: | ||
using: "composite" | ||
|
||
steps: | ||
- name: "Install PHIVE" | ||
shell: "bash" | ||
run: "${{ github.action_path }}/run.sh" | ||
env: | ||
PHIVE_DOT_PATH: "${{ inputs.home }}" | ||
PHIVE_BIN_PATH: "${{ inputs.binPath }}" | ||
PHIVE_SIGNING_KEY: "${{ inputs.signingKey }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/bash/travis_retry.bash | ||
retry() | ||
{ | ||
local -i result="0" | ||
local -i count="1" | ||
|
||
while [ "${count}" -le 3 ]; do | ||
if [ "${result}" -ne 0 ]; then | ||
echo | ||
echo "The command \"${*}\" failed. Retrying, ${count} of 3." 1>&2 | ||
echo | ||
fi | ||
# Run the command in a way that doesn't disable setting `errexit` | ||
if "${@}"; then | ||
break | ||
else | ||
result="${?}" | ||
fi | ||
count+="1" | ||
sleep 1 | ||
done | ||
|
||
if [ "${count}" -gt 3 ]; then | ||
echo | ||
echo "The command \"${*}\" failed 3 times." 1>&2 | ||
echo | ||
fi | ||
|
||
return "${result}" | ||
} | ||
|
||
set -e | ||
|
||
if [ ! -r "${PHIVE_DOT_PATH}/phive.phar" ]; then | ||
mkdir -p "${PHIVE_DOT_PATH}" | ||
|
||
if php -r 'exit(version_compare(PHP_VERSION, "7.2.0", "<") ? 0 : 1);'; then | ||
# Last phive version supporting PHP 7.1: v0.13.3 | ||
retry wget --tries=1 --output-document="${PHIVE_DOT_PATH}/phive.phar" "https://github.com/phar-io/phive/releases/download/0.13.3/phive-0.13.3.phar" | ||
retry wget --tries=1 --output-document="${PHIVE_DOT_PATH}/phive.phar.asc" "https://github.com/phar-io/phive/releases/download/0.13.3/phive-0.13.3.phar.asc" | ||
else | ||
retry wget --tries=1 --output-document="${PHIVE_DOT_PATH}/phive.phar" "https://phar.io/releases/phive.phar" | ||
retry wget --tries=1 --output-document="${PHIVE_DOT_PATH}/phive.phar.asc" "https://phar.io/releases/phive.phar.asc" | ||
fi | ||
retry gpg --batch --keyserver ha.pool.sks-keyservers.net --keyserver-options timeout=30 --recv-keys "${PHIVE_SIGNING_KEY}" | ||
if ! gpg --batch --verify "${PHIVE_DOT_PATH}/phive.phar.asc" "${PHIVE_DOT_PATH}/phive.phar"; then | ||
echo "Invalid phive signature" 1>&2 | ||
rm -f "${PHIVE_DOT_PATH}/phive.phar" | ||
exit 11 | ||
fi | ||
rm "${PHIVE_DOT_PATH}/phive.phar.asc" | ||
fi | ||
|
||
install --verbose --mode=0755 --no-target-directory -D "${PHIVE_DOT_PATH}/phive.phar" "${PHIVE_BIN_PATH}" |