-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
109 lines (101 loc) · 3.51 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
name: "Checkout and Build"
description: ""
inputs:
path:
description: "Path"
required: true
satis_key:
description: "SatisPress Key (packages.saucal.com)"
required: false
default: ''
node_version:
description: "The Node version for actions/setup-node"
required: false
default: '16'
php_version:
description: "The PHP version for actions/setup-php"
required: false
default: 'latest'
php_extensions:
description: "The extensions parameter for actions/setup-php"
required: false
default: 'mbstring'
composer_version:
description: "The Composer version for actions/setup-php"
required: false
default: 'v2'
validate-composer:
description: "Validate composer?"
required: false
default: 'true'
runs:
using: "composite"
steps:
- uses: "shivammathur/setup-php@v2"
if: ${{ hashFiles( '**/composer.json' ) != '' }}
with:
php-version: "${{ inputs.php_version }}"
tools: "composer:${{ inputs.composer_version }}"
extensions: "${{ inputs.php_extensions }}"
- name: Get composer store directory
if: ${{ hashFiles( '**/composer.json' ) != '' }}
id: composer-cache-setup
shell: bash
run: |
echo "cache_dir=$(composer global config cache-dir)" >> "$GITHUB_OUTPUT"
echo "hash=${{ hashFiles( '**/composer.json', '**/composer.lock' ) }}" >> "$GITHUB_OUTPUT"
- name: Cache composer
if: ${{ hashFiles( '**/composer.json' ) != '' }}
id: cache-composer
uses: actions/cache@v3
env:
cache-name: cache-composer
with:
path: ${{ steps.composer-cache-setup.outputs.cache_dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.composer-cache-setup.outputs.hash }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- uses: actions/setup-node@v3
if: ${{ hashFiles( '**/package.json' ) != '' }}
with:
node-version: ${{ inputs.node_version }}
- uses: pnpm/[email protected]
if: ${{ hashFiles( '**/pnpm-lock.yaml' ) != '' }}
name: Install pnpm
id: pnpm-install
with:
version: 6
- name: Get npm store directory
if: ${{ hashFiles( '**/package.json' ) != '' }}
id: npm-cache-setup
shell: bash
run: |
if [ "${{ hashFiles( '**/pnpm-lock.yaml' ) != '' }}" == "true" ]; then
echo "cache_dir=$(pnpm store path)" >> "$GITHUB_OUTPUT"
echo "hash=${{ hashFiles( '**/package.json', '**/pnpm-lock.yaml' ) }}" >> "$GITHUB_OUTPUT"
else
echo "cache_dir=~/.npm" >> "$GITHUB_OUTPUT"
echo "hash=${{ hashFiles( '**/package.json', '**/package-lock.json' ) }}" >> "$GITHUB_OUTPUT"
fi
- name: Cache node modules
if: ${{ hashFiles( '**/package.json' ) != '' }}
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ${{ steps.npm-cache-setup.outputs.cache_dir }}
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.npm-cache-setup.outputs.hash }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Maybe Build And Cleanup
shell: bash
env:
BUILD_DIR: ${{ inputs.path }}
SATIS_KEY: ${{ inputs.satis_key }}
VALIDATE_COMPOSER: ${{ inputs.validate-composer }}
run: "${{ github.action_path }}/maybe-build.sh"