#1 : Publish generic package to gitea #2

Merged
devastator merged 36 commits from feature/1-publish into master 2026-09-28 01:07:59 +03:00
3 changed files with 89 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
name: Core Build (push)
on:
push:
branches-ignore:
- master
env:
ACTI_BOT_TOKEN: ${{ secrets.ACTI_BOT_TOKEN }}
jobs:
self-test:
runs-on: ubuntu-latest
steps:
- run: touch text.txt
- uses: https://source.vague.tech/open-vague/ci-actions/publish@feature/1-publish
with:
file: text.txt
package: a-proper-test-package
version: master
force: true
+25
View File
@@ -1,2 +1,27 @@
# gitea-actions # gitea-actions
## Setup
For these actions to work properly one needs a bot account for the token. So, once the bot account is created, generate a token for it with `repository:write` and `package:write` permissions. However that's not enough, even making the bot a repository collaborator is not enough. The bot needs to have permissions on the organization level.
The recommended way is to create a team in the organization that has access to all repositories and set `Releases:Write` and `Packages:Write` permissions and `Read` for all the rest (yet, strictly speaking that's not necessary) and add the bot to the team.
The workflow (or jobs individually) needs to define an env variable `ACTI_BOT_TOKEN` with the bots token (as secrets do not automatically propagate into composite action context, at least it didn't work while testing).
## Publish
Publishes a `generic` package to current Gitea instance. Example:
```yaml
- uses: https://source.vague.tech/open-vague/ci-actions/publish@feature/1-publish
with:
file: some-content.json
package: the-package
version: master
force: true
```
* `file` - path to the file to upload (used as uploaded file name within the package)
* `package` - the package name
* `version` - the package version, need to be unique (unless force flag is set)
* `force` - false by default; if set **deletes the whole version** of the package (all files) and then publishes instead with the same version
+44
View File
@@ -0,0 +1,44 @@
name: publish generic package
description: publish generic package into gitea packages
inputs:
file:
description: file to upload as package
required: true
package:
description: gitea package name
required: true
version:
description: gitea package version
required: true
force:
description: force package replacement keeping the same version
required: false
default: "false"
runs:
using: composite
steps:
- shell: bash
run: |
set -euo pipefail
if [[ "${{ inputs.force }}" == "true" ]]; then
status="$(
curl --silent --show-error --output /dev/null --write-out '%{http_code}' \
--user "acti-bot:${ACTI_BOT_TOKEN}" \
--request DELETE \
"${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/${{ inputs.package }}/${{ inputs.version }}"
)"
case "$status" in
204|404) ;;
*)
echo "Failed to delete existing package version (HTTP ${status})" >&2
exit 1
;;
esac
fi
curl --fail-with-body \
--user "acti-bot:${ACTI_BOT_TOKEN}" \
--upload-file ${{ inputs.file }} \
"${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/${{ inputs.package }}/${{ inputs.version }}/${{ inputs.file }}"