update the workflow
Build Overleaf Release / build-and-release (push) Successful in 5s Details

This commit is contained in:
Master 2026-06-13 17:41:19 +03:30
parent a118ea5c94
commit e3b82c6509
1 changed files with 27 additions and 7 deletions

View File

@ -9,8 +9,11 @@ jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Checkout Code (Intranet Workaround)
run: |
# Bypass external GitHub Actions by manually cloning from the local Gitea instance
git clone https://oauth2:${{ secrets.GITHUB_TOKEN }}@git.amirkabirpark.ir/${{ gitea.repository }}.git .
git checkout ${{ gitea.ref_name }}
- name: Create Clean ZIP for Overleaf
run: |
@ -18,8 +21,25 @@ jobs:
# Exclude the .git folder and any github/gitea workflow files
zip -r Overleaf_Park__ReportTemplate-${{ gitea.ref_name }}.zip . -x "*.git*" -x "*.gitea*"
- name: Upload to Gitea Release
uses: https://gitea.com/actions/release-action@main
with:
files: Overleaf_Park__ReportTemplate-${{ gitea.ref_name }}.zip
api_key: ${{ secrets.GITHUB_TOKEN }}
- name: Upload to Gitea Release (Intranet Workaround)
run: |
ZIP_NAME="Overleaf_Park__ReportTemplate-${{ gitea.ref_name }}.zip"
API_BASE="https://git.amirkabirpark.ir/api/v1/repos/${{ gitea.repository }}"
# 1. Fetch the Release ID associated with this tag using Gitea's local API
RELEASE_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$API_BASE/releases/tags/${{ gitea.ref_name }}")
RELEASE_ID=$(echo "$RELEASE_DATA" | jq -r '.id')
# 2. If a release record doesn't exist yet, create an empty one
if [ "$RELEASE_ID" == "null" ] || [ -z "$RELEASE_ID" ]; then
CREATE_DATA=$(curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"${{ gitea.ref_name }}\", \"name\": \"${{ gitea.ref_name }}\"}" \
"$API_BASE/releases")
RELEASE_ID=$(echo "$CREATE_DATA" | jq -r '.id')
fi
# 3. Upload the ZIP artifact directly to the release attachment endpoint
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-F "attachment=@$ZIP_NAME" \
"$API_BASE/releases/$RELEASE_ID/assets?name=$ZIP_NAME"