ci: remove docker gha cache and publish charts to gitea
This commit is contained in:
@@ -52,8 +52,6 @@ jobs:
|
|||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
- name: Make container image public
|
- name: Make container image public
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
|
|||||||
@@ -40,6 +40,61 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
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
|
- name: Log in to registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -92,6 +92,56 @@ jobs:
|
|||||||
TAG: ${{ github.ref_name }}
|
TAG: ${{ github.ref_name }}
|
||||||
run: gh release upload "$TAG" "$CHART_PACKAGE" --clobber
|
run: gh release upload "$TAG" "$CHART_PACKAGE" --clobber
|
||||||
|
|
||||||
|
- name: Upload Helm chart artifact to Gitea release
|
||||||
|
if: steps.version.outputs.is_app_release == 'true' && 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
|
||||||
|
|
||||||
|
if [ ! -f "$CHART_PACKAGE" ]; then
|
||||||
|
echo "Chart package not found: $CHART_PACKAGE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
api="${GITEA_BASE_URL}/api/v1/repos/${GITEA_REPO}"
|
||||||
|
file_name=$(basename "$CHART_PACKAGE")
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
|
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_PACKAGE}" \
|
||||||
|
"${api}/releases/${release_id}/assets?name=${file_name}"
|
||||||
|
|
||||||
- name: Log in to registry
|
- name: Log in to registry
|
||||||
if: steps.version.outputs.is_app_release == 'true'
|
if: steps.version.outputs.is_app_release == 'true'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
|||||||
Reference in New Issue
Block a user