2.4 KiB
pack
Pack is web server written in rust with axum for hosting built packages as a destination endpoint for packages in a continuous integration workflow. It is designed around Gitea, using it for its authentication as well as integrating with Gitea actions.
Setup
To setup the server, rename pack.yml.template to
pack.yml and fill in the details for your configuration.
Place the built executable in a folder with properly configured
permissions, and make sure the upload path has permissions
750. Indeed, all subdirectories are created with this
permissions, and all files are created with 640.
Actions
The repository also includes a Gitea action. The arguments are
inputs:
file: ... # The file to upload.
feature: ... # The feature category for pack, i.e docs.
secret: ${{ secrets.PackRepo }} # The authorization secret for this repository.
prefix: ... # An optional prefix for the filename.
is_folder: ... # Specify as 'true' if you are deliberately uploading a folder. Pack chooses to enforce naming schemes depending on the type of
trigger, looking at the gitea.ref context variable, which
is the fully formed reference. In the case this is a git reference, the
filename will be {prefix}-{ref_name}-{sha}. For actions
triggered by releases, the gitea.ref is defined as the
release tag, and the filename becomes
{prefix}-{release}.
API
The only API endpoint intended to be exposed is
/api/files/{owner}/{repo}/{*path}, which supports
GET and DELETE. Every request requires an
Bearer Authorization token, which should be exactly the Gitea OAuth2
token. This API is intended for scripted management of uploaded packages
in the contiguous integration (CI) chain. For instance, automatically
pulling latest versions into a production environment.
GET
In the case, of GET, a JSON of the entries in a directory is returned. The format is shown below.
{
"entries": [
{
name: "...",
name_uri: "...",
icon: "...",
size: "...",
},
...
]
}If the requested path is a file, it will redirect to download the
file. If using curl, make sure the -L flag is
enabled to follow redirects.
DELETE
This will delete the file at the destination, or delete the entire directory. Use with caution.