1+ name : Sync to Codeberg
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ version :
7+ description : ' Version Tag (e.g. v1.1.0)'
8+ required : true
9+
10+ jobs :
11+ mirror-and-release :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - name : Checkout Code
15+ uses : actions/checkout@v3
16+ with :
17+ fetch-depth : 0
18+
19+ - name : Mirror to Codeberg (Manual Git Push)
20+ run : |
21+ git remote add codeberg "https://M-Rajabi-Dev:${{ secrets.CODEBERG_TOKEN }}@codeberg.org/M-Rajabi-Dev/AudioShelf.git"
22+ git push -f codeberg main
23+ git push -f codeberg --tags
24+
25+ - name : Download Assets from GitHub
26+ env :
27+ GH_TOKEN : ${{ github.token }}
28+ run : |
29+ gh release download ${{ inputs.version }} -p "*Setup.exe" -p "*Portable.zip" --dir ./assets
30+
31+ - name : Create Release on Codeberg
32+ env :
33+ CB_TOKEN : ${{ secrets.CODEBERG_TOKEN }}
34+ VERSION : ${{ inputs.version }}
35+ REPO : ' M-Rajabi-Dev/AudioShelf'
36+ run : |
37+ EXISTING_ID=$(curl -s "https://codeberg.org/api/v1/repos/$REPO/releases" | jq -r ".[] | select(.tag_name==\"$VERSION\") | .id")
38+ if [ ! -z "$EXISTING_ID" ]; then
39+ curl -X DELETE "https://codeberg.org/api/v1/repos/$REPO/releases/$EXISTING_ID" \
40+ -H "Authorization: token $CB_TOKEN"
41+ fi
42+
43+ RESPONSE=$(curl -X POST "https://codeberg.org/api/v1/repos/$REPO/releases" \
44+ -H "accept: application/json" \
45+ -H "Authorization: token $CB_TOKEN" \
46+ -H "Content-Type: application/json" \
47+ -d "{ \"tag_name\": \"$VERSION\", \"name\": \"AudioShelf $VERSION\", \"body\": \"Mirrored from GitHub\" }")
48+
49+ echo "RELEASE_ID=$(echo $RESPONSE | jq -r .id)" >> $GITHUB_ENV
50+
51+ - name : Upload Assets to Codeberg
52+ env :
53+ CB_TOKEN : ${{ secrets.CODEBERG_TOKEN }}
54+ REPO : ' M-Rajabi-Dev/AudioShelf'
55+ run : |
56+ cd assets
57+ for file in *; do
58+ curl -X POST "https://codeberg.org/api/v1/repos/$REPO/releases/${{ env.RELEASE_ID }}/assets?name=$file" \
59+ -H "accept: application/json" \
60+ -H "Authorization: token $CB_TOKEN" \
61+ -H "Content-Type: multipart/form-data" \
62+ -F "attachment=@$file"
63+ done
0 commit comments