-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
138 lines (125 loc) · 4.39 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: 'Generate Composer Satis Repository'
author: 'Matt Walsh'
description: 'Builds a Composer Satis repository and outputs the build as a GitHub workflow artifact.'
branding:
icon: download-cloud
color: purple
inputs:
php-version:
description: 'The version of PHP to use.'
required: false
default: '8.3'
composer-token:
description: 'Token for Composer authentication.'
required: false
composer-version:
description: 'The version of Composer to use.'
required: false
default: '2.6'
satis-version:
description: 'Version of Satis to use.'
required: false
default: 'main'
satis-config:
description: 'Location of the Satis JSON config file.'
required: false
cache-composer:
description: 'Whether to cache the Composer cache directory.'
required: false
default: 'true'
artifact-name:
description: 'Final build artifact name.'
required: false
default: 'modules-repository-build'
retention-days:
description: 'Duration to keep the build artifact, in days.'
required: false
default: '90'
repository-url:
description: 'Repository URL for partial updates.'
required: false
outputs:
satis-artifact:
description: "The final artifact name."
value: ${{ steps.output-artifact-name.outputs.satis-artifact }}
runs:
using: 'composite'
steps:
- id: setup-php
name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
tools: composer:${{ inputs.composer-version }}
coverage: none
- id: configure-composer
name: 'Configure Composer GitHub Token'
run: |
if [ -n "${{ inputs.composer-token }}" ]; then
composer config --global --auth github-oauth.github.com ${{ inputs.composer-token }}
else
composer config --global --auth github-oauth.github.com ${{ github.token }}
fi
shell: bash
- id: download-satis
name: 'Install Satis Via Git Clone'
run: |
git clone https://github.com/composer/satis.git ${{ env.SATIS_PATH }}
cd ${{ env.SATIS_PATH }}
git checkout ${{ inputs.satis-version }}
shell: bash
- id: get-composer-cache-dir-path
if: ${{ inputs.cache-composer == 'true' }}
name: 'Set Composer Cache Directory Path Output'
run: |
cd ${{ env.SATIS_PATH }}
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "$(composer config cache-files-dir)"
shell: bash
- id: cache-composer
if: ${{ inputs.cache-composer == 'true' }}
name: 'Cache Composer Cache Directory'
uses: actions/cache@v4
with:
path: ${{ steps.get-composer-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('satis/composer.lock') }}
- id: run-satis-composer-install
name: 'Run Composer Install'
run: |
cd ${{ env.SATIS_PATH }}
composer install --no-progress --prefer-dist --optimize-autoloader
shell: bash
- id: run-satis
name: 'Run Satis'
run: |
cd ${{ env.SATIS_PATH }}
SATIS_CONFIG_PATH="${{ github.workspace }}/satis.json"
if [ -n "${{ inputs.satis-config }}" ]; then
SATIS_CONFIG_PATH="${{ github.workspace }}/${{ inputs.satis-config }}/satis.json"
fi
SATIS_BUILD_COMMAND="bin/satis build \"$SATIS_CONFIG_PATH\" ${{ env.SATIS_PATH }}/dist"
if [ -n "${{ inputs.repository-url }}" ]; then
SATIS_BUILD_COMMAND="bin/satis build --repository-url ${{ inputs.repository-url }} \"$SATIS_CONFIG_PATH\" ${{ env.SATIS_PATH }}/dist"
fi
echo $SATIS_BUILD_COMMAND
eval $SATIS_BUILD_COMMAND
shell: bash
- id: create-tarball
name: 'Create Tarball Of Build'
run: |
cd ${{ env.SATIS_PATH }}/dist
tar -cf ../modules-repository-build.tar *
shell: bash
- id: upload-artifact
name: 'Upload Build As Artifact'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}-${{ github.run_id }}
path: ${{ env.SATIS_PATH }}/${{ inputs.artifact-name }}.tar
retention-days: ${{ inputs.retention-days }}
if-no-files-found: error
- id: output-artifact-name
if: ${{ success() }}
name: 'Set Artifact Name As Output'
run: echo "satis-artifact=${{ inputs.artifact-name }}-${{ github.run_id }}" >> $GITHUB_OUTPUT
shell: bash