ci: remove docker gha cache and publish charts to gitea
This commit is contained in:
@@ -40,6 +40,61 @@ jobs:
|
||||
env:
|
||||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
- name: Upload chart artifacts to Gitea release
|
||||
if: secrets.GITEA_TOKEN != ''
|
||||
env:
|
||||
GITEA_BASE_URL: https://git.kloude.ir
|
||||
GITEA_REPO: kloude/kks-provider-plugin
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
shopt -s nullglob
|
||||
charts=(.cr-release-packages/*.tgz)
|
||||
if [ ${#charts[@]} -eq 0 ]; then
|
||||
echo "No packaged charts to upload to Gitea"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
api="${GITEA_BASE_URL}/api/v1/repos/${GITEA_REPO}"
|
||||
|
||||
release_json=$(curl -fsS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${api}/releases/tags/${TAG}" || true)
|
||||
|
||||
if [ -z "$release_json" ]; then
|
||||
release_json=$(curl -fsS -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${api}/releases" \
|
||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"target_commitish\":\"${GITHUB_SHA}\"}")
|
||||
fi
|
||||
|
||||
release_id=$(python3 -c 'import json,sys; print(json.loads(sys.stdin.read())["id"])' <<< "$release_json")
|
||||
|
||||
existing_assets=$(curl -fsS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${api}/releases/${release_id}/assets")
|
||||
|
||||
for chart in "${charts[@]}"; do
|
||||
file_name=$(basename "$chart")
|
||||
|
||||
existing_asset_id=$(python3 -c 'import json,sys; assets=json.loads(sys.stdin.read()); name=sys.argv[1]; print(next((str(a["id"]) for a in assets if a.get("name")==name), ""))' "$file_name" <<< "$existing_assets")
|
||||
|
||||
if [ -n "$existing_asset_id" ]; then
|
||||
curl -fsS -X DELETE \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${api}/releases/${release_id}/assets/${existing_asset_id}"
|
||||
fi
|
||||
|
||||
curl -fsS -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/gzip" \
|
||||
--data-binary "@${chart}" \
|
||||
"${api}/releases/${release_id}/assets?name=${file_name}"
|
||||
done
|
||||
|
||||
- name: Log in to registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
|
||||
Reference in New Issue
Block a user