Update .gitea/workflows/demo.yaml
This commit is contained in:
@@ -8,6 +8,11 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GITEA_URL: https://10.1.1.1:8086
|
||||
GITEA_OWNER: derek
|
||||
GITEA_REPO: ${{ gitea.repository }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -30,8 +35,59 @@ jobs:
|
||||
- name: export server
|
||||
run: docker save mistox-website -o release/mistox-website.tar
|
||||
|
||||
- name: create release
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-release
|
||||
path: ${{ gitea.workspace }}/release
|
||||
- name: Create Gitea release and upload assets (without jq)
|
||||
id: gitea_release
|
||||
run: |
|
||||
TAG_NAME="v1.0.${GITHUB_RUN_NUMBER}"
|
||||
RELEASE_TITLE="Release $TAG_NAME"
|
||||
DESCRIPTION="Automated release from CI run $GITHUB_RUN_NUMBER"
|
||||
|
||||
RELEASE_JSON=$(cat <<EOF
|
||||
{
|
||||
"tag_name": "$TAG_NAME",
|
||||
"title": "$RELEASE_TITLE",
|
||||
"description": "$DESCRIPTION",
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
echo "Creating release $TAG_NAME on Gitea..."
|
||||
|
||||
RESPONSE=$(curl -s -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$RELEASE_JSON" \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/releases")
|
||||
|
||||
# Extract "id" value from JSON using grep + sed
|
||||
RELEASE_ID=$(echo "$RESPONSE" | grep -oP '"id":\s*\K[0-9]+')
|
||||
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "Failed to create release. Response:"
|
||||
echo "$RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Release created with ID $RELEASE_ID"
|
||||
|
||||
for asset in release/mistox-sql.tar release/mistox-website.tar; do
|
||||
FILENAME=$(basename "$asset")
|
||||
echo "Uploading $FILENAME..."
|
||||
|
||||
UPLOAD_RESPONSE=$(curl -s -X POST \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-F "name=$FILENAME" \
|
||||
-F "attachment=@$asset" \
|
||||
"$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/releases/$RELEASE_ID/assets")
|
||||
|
||||
# Simple success check by searching for "id" key in response
|
||||
if echo "$UPLOAD_RESPONSE" | grep -q '"id":'; then
|
||||
echo "Uploaded $FILENAME successfully."
|
||||
else
|
||||
echo "Failed to upload $FILENAME. Response:"
|
||||
echo "$UPLOAD_RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user