-
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
1 parent
9da9e98
commit 92ebc74
Showing
5 changed files
with
73 additions
and
19 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"printWidth": 80, | ||
"printWidth": 100, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
|
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
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
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
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,34 @@ | ||
const core = require('@actions/core'); | ||
|
||
async function validateInputs() { | ||
return new Promise(resolve => { | ||
// sapi, must be a valid PHP SAPI name, accepts cli,fpm,micro,embed | ||
const sapi = core.getInput('sapi', { required: true }); | ||
core.debug(`SAPI: ${sapi}`); | ||
// split comma separated values | ||
const sapisArray = sapi.split(',').map(s => s.trim()); | ||
// check if all values are valid, if some value is invalid, throw an error | ||
for (const s of sapisArray) { | ||
if (!['cli', 'fpm', 'micro', 'embed'].includes(s)) { | ||
throw new Error(`Invalid sapi: ${s}`); | ||
} | ||
} | ||
|
||
// php-version, must be a valid PHP version, accepts 8.0-8.3, and also patch versions, like 8.3.10 | ||
const phpVersion = core.getInput('php-version', { required: false }); | ||
core.debug(`PHP_VERSION: ${phpVersion}`); | ||
if (!phpVersion.match(/^8\.[0-3](\.\d+)?$/)) { | ||
throw new Error('Invalid php-version'); | ||
} | ||
|
||
// extensions, comma separated list of PHP extensions | ||
const extensions = core.getInput('extensions', { required: false }); | ||
if (!extensions.match(/^(\w+,)*\w+$/)) { | ||
throw new Error('Invalid extensions'); | ||
} | ||
|
||
resolve(); | ||
}); | ||
} | ||
|
||
module.exports = { validateInputs }; |