-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
92 lines (82 loc) · 2.71 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
name: 'Composer install'
description: 'Installs php with extentions and run composer install'
inputs:
PHP_VERSION:
description: 'PHP version to install'
required: true
PHP_EXTENSIONS:
description: 'extensions to install'
required: true
PHP_TOOLS:
description: 'tools to install'
required: false
default: 'phpcs:3.5.8'
CACHE_KEY:
description: 'cache key for cache busting'
required: false
default: 'cache_v1'
SSH_PRIVATE_KEY:
description: 'Private key to access github'
required: false
default: ''
SSH_PUBLIC_KEY:
description: 'Public key to access github'
required: false
default: ''
COMPOSER_DEFAULT_ARGUMENTS:
description: 'Default composer arguments, can be overriden if required'
required: false
default: '--no-progress --prefer-dist --optimize-autoloader'
COMPOSER_ARGUMENTS:
description: 'additional composer arguments which you require'
required: false
default: ''
runs:
using: "composite"
steps:
- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ inputs.PHP_VERSION }}
extensions: ${{ inputs.PHP_EXTENSIONS }}
key: ${{ inputs.CACHE_KEY }}
- name: Cache extensions
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.PHP_VERSION }}
extensions: ${{ inputs.PHP_EXTENSIONS }}
tools: ${{ inputs.PHP_TOOLS }}
- name: Get composer cache directory
shell: bash
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: setup ssh keys
shell: bash
env:
PRIVATE_KEY: ${{ inputs.SSH_PRIVATE_KEY }}
PUBLIC_KEY: ${{ inputs.SSH_PUBLIC_KEY }}
run: |
mkdir -p ~/.ssh
touch ~/.gitconfig
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
echo "$PRIVATE_KEY" > ~/.ssh/action_rsa
echo "$PUBLIC_KEY" > ~/.ssh/action_rsa.pub
chmod 600 ~/.ssh/action_rsa
git config --global core.sshCommand "ssh -i ~/.ssh/action_rsa"
- name: Install Composer dependencies
shell: bash
run: composer install ${{ inputs.COMPOSER_DEFAULT_ARGUMENTS }} ${{ inputs.COMPOSER_ARGUMENTS }}