You've already forked gitea-composer-upload-action
env variables validation
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
GITEA_INSTANCE_BASE_URL="https://gitea.example.com"
|
||||
GITEA_ACCESS_TOKEN="access_token"
|
||||
GITEA_OWNER="owner"
|
||||
GITEA_REPOSITORY="repository"
|
||||
GITEA_REPOSITORY="repository"
|
||||
GITEA_PACKAGE_REGISTRY="composer"
|
||||
@@ -10,6 +10,7 @@ services:
|
||||
GITEA_ACCESS_TOKEN: ${GITEA_ACCESS_TOKEN}
|
||||
GITEA_OWNER: ${GITEA_OWNER}
|
||||
GITEA_REPOSITORY: ${GITEA_REPOSITORY}
|
||||
GITEA_PACKAGE_REGISTRY: ${GITEA_PACKAGE_REGISTRY}
|
||||
volumes:
|
||||
- ./src:/var/src
|
||||
networks:
|
||||
|
||||
24
src/app.php
24
src/app.php
@@ -104,6 +104,30 @@ function showTerminalMessage (string $message = '', string $color = ''): void
|
||||
|
||||
try {
|
||||
|
||||
if (empty(\getenv('GITEA_INSTANCE_BASE_URL'))) {
|
||||
throw new \Exception('GITEA_INSTANCE_BASE_URL empty');
|
||||
}
|
||||
|
||||
if (empty(\getenv('GITEA_ACCESS_TOKEN'))) {
|
||||
throw new \Exception('GITEA_ACCESS_TOKEN empty');
|
||||
}
|
||||
|
||||
if (empty(\getenv('GITEA_OWNER'))) {
|
||||
throw new \Exception('GITEA_OWNER empty');
|
||||
}
|
||||
|
||||
if (empty(\getenv('GITEA_REPOSITORY'))) {
|
||||
throw new \Exception('GITEA_REPOSITORY empty');
|
||||
}
|
||||
|
||||
if (empty(\getenv('GITEA_PACKAGE_REGISTRY'))) {
|
||||
throw new \Exception('GITEA_PACKAGE_REGISTRY empty');
|
||||
}
|
||||
|
||||
if (!\in_array(\getenv('GITEA_PACKAGE_REGISTRY'), ['composer'])) {
|
||||
throw new \Exception('Package registry {' . \getenv('GITEA_PACKAGE_REGISTRY') . '} is not supported');
|
||||
}
|
||||
|
||||
$response = sendRequest('GET', '/api/v1/user');
|
||||
$data = responseEncode($response);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user