Skip to content

Commit 1ff14e3

Browse files
committed
Add Sync to Codeberg action
1 parent fd10530 commit 1ff14e3

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Mirror Code to Codeberg
20+
uses: yesolutions/mirror-action@v1
21+
with:
22+
REMOTE: 'https://codeberg.org/M-Rajabi-Dev/AudioShelf.git'
23+
GIT_USERNAME: M-Rajabi-Dev
24+
GIT_PASSWORD: ${{ secrets.CODEBERG_TOKEN }}
25+
26+
- name: Download Assets from GitHub
27+
env:
28+
GH_TOKEN: ${{ github.token }}
29+
run: |
30+
gh release download ${{ inputs.version }} -p "*Setup.exe" -p "*Portable.zip" --dir ./assets
31+
32+
- name: Create Release on Codeberg
33+
env:
34+
CB_TOKEN: ${{ secrets.CODEBERG_TOKEN }}
35+
VERSION: ${{ inputs.version }}
36+
REPO: 'M-Rajabi-Dev/AudioShelf'
37+
run: |
38+
RESPONSE=$(curl -X POST "https://codeberg.org/api/v1/repos/$REPO/releases" \
39+
-H "accept: application/json" \
40+
-H "Authorization: token $CB_TOKEN" \
41+
-H "Content-Type: application/json" \
42+
-d "{ \"tag_name\": \"$VERSION\", \"name\": \"AudioShelf $VERSION\", \"body\": \"Mirrored from GitHub\" }")
43+
44+
echo "RELEASE_ID=$(echo $RESPONSE | jq -r .id)" >> $GITHUB_ENV
45+
46+
- name: Upload Assets to Codeberg
47+
env:
48+
CB_TOKEN: ${{ secrets.CODEBERG_TOKEN }}
49+
REPO: 'M-Rajabi-Dev/AudioShelf'
50+
run: |
51+
cd assets
52+
for file in *; do
53+
curl -X POST "https://codeberg.org/api/v1/repos/$REPO/releases/${{ env.RELEASE_ID }}/assets?name=$file" \
54+
-H "accept: application/json" \
55+
-H "Authorization: token $CB_TOKEN" \
56+
-H "Content-Type: multipart/form-data" \
57+
-F "attachment=@$file"
58+
done

0 commit comments

Comments
 (0)