You've already forked gitea-composer-upload-action
github action configuration
This commit is contained in:
27
action.yml
Normal file
27
action.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
name: "Gitea updating package"
|
||||||
|
description: "Updating a package in the Gitea system using GitHub Actions"
|
||||||
|
inputs:
|
||||||
|
gitea_instance_base_url:
|
||||||
|
description: "gitea instance base url"
|
||||||
|
required: true
|
||||||
|
gitea_access_token:
|
||||||
|
description: "gitea access token"
|
||||||
|
required: true
|
||||||
|
gitea_owner:
|
||||||
|
description: "gitea owner"
|
||||||
|
required: true
|
||||||
|
gitea_repository:
|
||||||
|
description: "gitea repository"
|
||||||
|
required: true
|
||||||
|
gitea_package_registry:
|
||||||
|
description: "gitea package registry"
|
||||||
|
required: true
|
||||||
|
runs:
|
||||||
|
using: "docker"
|
||||||
|
image: "Dockerfile"
|
||||||
|
args:
|
||||||
|
- ${{ inputs.gitea_instance_base_url }}
|
||||||
|
- ${{ inputs.gitea_access_token }}
|
||||||
|
- ${{ inputs.gitea_owner }}
|
||||||
|
- ${{ inputs.gitea_repository }}
|
||||||
|
- ${{ inputs.gitea_package_registry }}
|
||||||
@@ -6,11 +6,11 @@ services:
|
|||||||
context: ./
|
context: ./
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
environment:
|
environment:
|
||||||
GITEA_INSTANCE_BASE_URL: ${GITEA_INSTANCE_BASE_URL}
|
gitea_instance_base_url: ${GITEA_INSTANCE_BASE_URL}
|
||||||
GITEA_ACCESS_TOKEN: ${GITEA_ACCESS_TOKEN}
|
gitea_access_token: ${GITEA_ACCESS_TOKEN}
|
||||||
GITEA_OWNER: ${GITEA_OWNER}
|
gitea_owner: ${GITEA_OWNER}
|
||||||
GITEA_REPOSITORY: ${GITEA_REPOSITORY}
|
gitea_repository: ${GITEA_REPOSITORY}
|
||||||
GITEA_PACKAGE_REGISTRY: ${GITEA_PACKAGE_REGISTRY}
|
gitea_package_registry: ${GITEA_PACKAGE_REGISTRY}
|
||||||
volumes:
|
volumes:
|
||||||
- ./src:/var/src
|
- ./src:/var/src
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
34
src/app.php
34
src/app.php
@@ -33,10 +33,10 @@ function sendRequest ($method = 'GET', $endpoint = '', $data = []): array {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data['user']) && !empty($data['user'])) {
|
if (isset($data['user']) && !empty($data['user'])) {
|
||||||
\curl_setopt($curl, CURLOPT_USERPWD, $data['user'] . ':' . \getenv('GITEA_ACCESS_TOKEN'));
|
\curl_setopt($curl, CURLOPT_USERPWD, $data['user'] . ':' . \getenv('gitea_access_token'));
|
||||||
}
|
}
|
||||||
|
|
||||||
\curl_setopt($curl, CURLOPT_URL, \getenv('GITEA_INSTANCE_BASE_URL') . $endpoint .'?access_token=' . \getenv('GITEA_ACCESS_TOKEN'));
|
\curl_setopt($curl, CURLOPT_URL, \getenv('gitea_instance_base_url') . $endpoint .'?access_token=' . \getenv('gitea_access_token'));
|
||||||
\curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
|
\curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
|
||||||
\curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
|
\curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
|
||||||
\curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
\curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
@@ -104,28 +104,28 @@ function showTerminalMessage (string $message = '', string $color = ''): void
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (empty(\getenv('GITEA_INSTANCE_BASE_URL'))) {
|
if (empty(\getenv('gitea_instance_base_url'))) {
|
||||||
throw new \Exception('GITEA_INSTANCE_BASE_URL empty');
|
throw new \Exception('gitea_instance_base_url empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty(\getenv('GITEA_ACCESS_TOKEN'))) {
|
if (empty(\getenv('gitea_access_token'))) {
|
||||||
throw new \Exception('GITEA_ACCESS_TOKEN empty');
|
throw new \Exception('gitea_access_token empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty(\getenv('GITEA_OWNER'))) {
|
if (empty(\getenv('gitea_owner'))) {
|
||||||
throw new \Exception('GITEA_OWNER empty');
|
throw new \Exception('gitea_owner empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty(\getenv('GITEA_REPOSITORY'))) {
|
if (empty(\getenv('gitea_repository'))) {
|
||||||
throw new \Exception('GITEA_REPOSITORY empty');
|
throw new \Exception('gitea_repository empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty(\getenv('GITEA_PACKAGE_REGISTRY'))) {
|
if (empty(\getenv('gitea_package_registry'))) {
|
||||||
throw new \Exception('GITEA_PACKAGE_REGISTRY empty');
|
throw new \Exception('gitea_package_registry empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!\in_array(\getenv('GITEA_PACKAGE_REGISTRY'), ['composer'])) {
|
if (!\in_array(\getenv('gitea_package_registry'), ['composer'])) {
|
||||||
throw new \Exception('Package registry {' . \getenv('GITEA_PACKAGE_REGISTRY') . '} is not supported');
|
throw new \Exception('Package registry {' . \getenv('gitea_package_registry') . '} is not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = sendRequest('GET', '/api/v1/user');
|
$response = sendRequest('GET', '/api/v1/user');
|
||||||
@@ -141,7 +141,7 @@ try {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$response = sendRequest('GET', '/api/v1/repos/' . \getenv('GITEA_OWNER') . '/' . \getenv('GITEA_REPOSITORY') . '/releases');
|
$response = sendRequest('GET', '/api/v1/repos/' . \getenv('gitea_owner') . '/' . \getenv('gitea_repository') . '/releases');
|
||||||
$data = responseEncode($response);
|
$data = responseEncode($response);
|
||||||
|
|
||||||
if ($response['http_code'] !== 200) {
|
if ($response['http_code'] !== 200) {
|
||||||
@@ -157,7 +157,7 @@ try {
|
|||||||
showTerminalMessage('Last release data: OK', GREEN);
|
showTerminalMessage('Last release data: OK', GREEN);
|
||||||
|
|
||||||
|
|
||||||
$response = sendRequest('GET', '/api/v1/repos/' . \getenv('GITEA_OWNER') . '/' . \getenv('GITEA_REPOSITORY') . '/archive/' . $tag . '.zip');
|
$response = sendRequest('GET', '/api/v1/repos/' . \getenv('gitea_owner') . '/' . \getenv('gitea_repository') . '/archive/' . $tag . '.zip');
|
||||||
$zipContent = $response['body'];
|
$zipContent = $response['body'];
|
||||||
|
|
||||||
if ($response['http_code'] !== 200) {
|
if ($response['http_code'] !== 200) {
|
||||||
@@ -173,7 +173,7 @@ try {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$response = sendRequest('PUT', '/api/packages/' . \getenv('GITEA_OWNER') . '/composer?version=' . $tag, [
|
$response = sendRequest('PUT', '/api/packages/' . \getenv('gitea_owner') . '/composer?version=' . $tag, [
|
||||||
'user' => $login,
|
'user' => $login,
|
||||||
'file' => __DIR__ . '/package.zip',
|
'file' => __DIR__ . '/package.zip',
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user