Skip to content

Sync to Codeberg

Sync to Codeberg #3

Workflow file for this run

name: Sync to Codeberg
on:
workflow_dispatch:
inputs:
version:
description: 'Version Tag (e.g. v1.1.0)'
required: true
jobs:
mirror-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Mirror Code to Codeberg
uses: yesolutions/mirror-action@v1
with:
REMOTE: 'https://codeberg.org/M-Rajabi-Dev/AudioShelf.git'
GIT_USERNAME: M-Rajabi-Dev
GIT_PASSWORD: ${{ secrets.CODEBERG_TOKEN }}
- name: Download Assets from GitHub
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download ${{ inputs.version }} -p "*Setup.exe" -p "*Portable.zip" --dir ./assets
- name: Create Release on Codeberg
env:
CB_TOKEN: ${{ secrets.CODEBERG_TOKEN }}
VERSION: ${{ inputs.version }}
REPO: 'M-Rajabi-Dev/AudioShelf'
run: |
RESPONSE=$(curl -X POST "https://codeberg.org/api/v1/repos/$REPO/releases" \
-H "accept: application/json" \
-H "Authorization: token $CB_TOKEN" \
-H "Content-Type: application/json" \
-d "{ \"tag_name\": \"$VERSION\", \"name\": \"AudioShelf $VERSION\", \"body\": \"Mirrored from GitHub\" }")
echo "RELEASE_ID=$(echo $RESPONSE | jq -r .id)" >> $GITHUB_ENV
- name: Upload Assets to Codeberg
env:
CB_TOKEN: ${{ secrets.CODEBERG_TOKEN }}
REPO: 'M-Rajabi-Dev/AudioShelf'
run: |
cd assets
for file in *; do
curl -X POST "https://codeberg.org/api/v1/repos/$REPO/releases/${{ env.RELEASE_ID }}/assets?name=$file" \
-H "accept: application/json" \
-H "Authorization: token $CB_TOKEN" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@$file"
done