45 lines
2.1 KiB
YAML
45 lines
2.1 KiB
YAML
name: Build Overleaf Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*' # Triggers on any tag starting with 'v'
|
|
|
|
jobs:
|
|
build-and-release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- 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: |
|
|
# Zip everything in the current directory (.) without a wrapper folder
|
|
# 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 (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" |