mirror of
https://github.com/rosven9856/gitea_creating_release_action.git
synced 2025-09-06 02:02:54 +08:00
First version creating github action
This commit is contained in:
parent
0bd0214089
commit
423260bcde
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/.idea
|
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM alpine:3.18.4
|
||||
|
||||
RUN apk update
|
||||
RUN apk add --no-cache curl
|
||||
RUN apk add --no-cache jq
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
57
README.md
Normal file
57
README.md
Normal file
@ -0,0 +1,57 @@
|
||||
# Creating a release in Gitea
|
||||
|
||||
This action will create a new release in the Gitea system using the API and output all debugging information to the log.
|
||||
See from detail https://docs.gitea.com/api/1.20/#tag/repository/operation/repoCreateRelease
|
||||
|
||||
## Inputs
|
||||
|
||||
## `gitea_schema`
|
||||
Gitea schema.
|
||||
|
||||
## `gitea_host`
|
||||
**Required** Gitea host.
|
||||
|
||||
## `gitea_organization`
|
||||
**Required** Gitea organization or user.
|
||||
|
||||
## `gitea_repo`
|
||||
**Required** Gitea repository.
|
||||
|
||||
## `access_token`
|
||||
**Required** Gitea access token for interacting with the API.
|
||||
|
||||
## `release_body`
|
||||
**Required** Option {body} in request to api.
|
||||
|
||||
## `release_draft`
|
||||
**Required** Option {draft} in request to api.
|
||||
|
||||
## `release_name`
|
||||
**Required** Option {name} in request to api.
|
||||
|
||||
## `release_prerelease`
|
||||
**Required** Option {prerelease} in request to api.
|
||||
|
||||
## `release_tag_name`
|
||||
**Required** Option {tag_name} in request to api.
|
||||
|
||||
## `release_target_commitish`
|
||||
**Required** Option {target_commitish} in request to api.
|
||||
|
||||
## Example usage
|
||||
|
||||
```yml
|
||||
uses: actions/gitea_create_release_action@master
|
||||
with:
|
||||
gitea_schema: "https"
|
||||
gitea_host: "gitea.example.org"
|
||||
gitea_organization: "organization"
|
||||
gitea_repo: "repository"
|
||||
access_token: "${{ secrets.GITEA_ACCESS_TOKEN }}"
|
||||
release_body: ""
|
||||
release_draft: "true"
|
||||
release_name: "release_name"
|
||||
release_prerelease: "false"
|
||||
release_tag_name: "1.0.0"
|
||||
release_target_commitish: ""
|
||||
```
|
57
action.yml
Normal file
57
action.yml
Normal file
@ -0,0 +1,57 @@
|
||||
name: "gitea release create"
|
||||
description: "creating a new release through the API in the system gitea"
|
||||
inputs:
|
||||
gitea_schema:
|
||||
description: "gitea schema"
|
||||
default: "https"
|
||||
gitea_host:
|
||||
description: "gitea host"
|
||||
required: true
|
||||
gitea_organization:
|
||||
description: "gitea organization or user"
|
||||
required: true
|
||||
gitea_repo:
|
||||
description: "gitea repository"
|
||||
required: true
|
||||
access_token:
|
||||
description: "access token"
|
||||
required: true
|
||||
release_body:
|
||||
description: "option {body} in request to api"
|
||||
required: true
|
||||
default: ""
|
||||
release_draft:
|
||||
description: "option {draft} in request to api"
|
||||
required: true
|
||||
default: "true"
|
||||
release_name:
|
||||
description: "option {name} in request to api"
|
||||
required: true
|
||||
default: ""
|
||||
release_prerelease:
|
||||
description: "option {prerelease} in request to api"
|
||||
required: true
|
||||
default: "false"
|
||||
release_tag_name:
|
||||
description: "option {tag_name} in request to api"
|
||||
required: true
|
||||
default: ""
|
||||
release_target_commitish:
|
||||
description: "option {target_commitish} in request to api"
|
||||
required: true
|
||||
default: ""
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
args:
|
||||
- ${{ inputs.gitea_schema }}
|
||||
- ${{ inputs.gitea_host }}
|
||||
- ${{ inputs.gitea_organization }}
|
||||
- ${{ inputs.gitea_repo }}
|
||||
- ${{ inputs.access_token }}
|
||||
- ${{ inputs.release_body }}
|
||||
- ${{ inputs.release_draft }}
|
||||
- ${{ inputs.release_name }}
|
||||
- ${{ inputs.release_prerelease }}
|
||||
- ${{ inputs.release_tag_name }}
|
||||
- ${{ inputs.release_target_commitish }}
|
106
entrypoint.sh
Executable file
106
entrypoint.sh
Executable file
@ -0,0 +1,106 @@
|
||||
#!/bin/sh
|
||||
|
||||
RED='\033[0;31m';
|
||||
GREEN='\033[1;32m';
|
||||
YELLOW='\033[1;33m';
|
||||
LITE_CYAN='\e[96m';
|
||||
NC='\033[0m';
|
||||
|
||||
if [ -z ${gitea_schema} ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Error message: ${RED}Option {gitea_schema} is not set${NC} \n"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ ${gitea_schema} = '' ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Error message: ${RED}Option {gitea_schema} must be a non-empty string${NC} \n"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
|
||||
if [ -z ${gitea_host} ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Error message: ${RED}Option {gitea_host} is not set${NC} \n"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ ${gitea_host} = '' ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Error message: ${RED}Option {gitea_host} must be a non-empty string${NC} \n"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
|
||||
if [ -z ${gitea_organization} ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Error message: ${RED}Option {gitea_organization} is not set${NC} \n"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ ${gitea_organization} = '' ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Error message: ${RED}Option {gitea_organization} must be a non-empty string${NC} \n"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
|
||||
if [ -z ${gitea_repo} ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Error message: ${RED}Option {gitea_repo} is not set${NC} \n"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ ${gitea_repo} = '' ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Error message: ${RED}Option {gitea_repo} must be a non-empty string${NC} \n"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
|
||||
if [ -z ${access_token} ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Error message: ${RED}Option {access_token} is not set${NC} \n"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ ${access_token} = '' ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Error message: ${RED}Option {access_token} must be a non-empty string${NC} \n"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
printf "api request url=${YELLOW} ${gitea_schema}://${gitea_host}/api/v1/repos/${gitea_organization}/${gitea_repo}/releases ${NC} \n";
|
||||
printf "body=${YELLOW}${release_body}${NC} \n";
|
||||
printf "draft=${YELLOW}${release_draft}${NC} \n";
|
||||
printf "name=${YELLOW}${release_name}${NC} \n";
|
||||
printf "prerelease=${YELLOW}${release_prerelease}${NC} \n";
|
||||
printf "tag_name=${YELLOW}${release_tag_name}${NC} \n";
|
||||
printf "target_commitish=${YELLOW}${release_target_commitish}${NC} \n";
|
||||
|
||||
response=$( curl -X 'POST' \
|
||||
"${gitea_schema}://${gitea_host}/api/v1/repos/${gitea_organization}/${gitea_repo}/releases?access_token=${access_token}" \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d "{
|
||||
\"body\": \"${release_body}\",
|
||||
\"draft\": ${release_draft},
|
||||
\"name\": \"${release_name}\",
|
||||
\"prerelease\": ${release_prerelease},
|
||||
\"tag_name\": \"${release_tag_name}\",
|
||||
\"target_commitish\": \"${release_target_commitish}\"
|
||||
}")
|
||||
|
||||
id=$(echo $response | jq '.id');
|
||||
url=$(echo $response | jq '.html_url');
|
||||
message=$(echo $response | jq '.message');
|
||||
|
||||
if [ $id = 'null' ]; then
|
||||
printf "${RED}FAILED${NC} \n"
|
||||
printf "Create release error: Error message: ${RED}$message${NC} \n"
|
||||
exit 1;
|
||||
else
|
||||
printf "${GREEN}SUCCESS${NC} \n"
|
||||
printf "Created release: id: ${YELLOW}$id${NC} \nurl: ${YELLOW}$url${NC} \n"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user