diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d49f882..1d27a79 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,43 +13,38 @@ jobs: - name: check path run: | pwd - - - name: build debian images - run: | - bash build_images.sh debian - + - name: Configure Git run: | git config --global user.name "daily-update" git config --global user.email "tg@spiritlhl.top" - - name: List and upload zip files + - name: Build and Upload Images run: | - - name: List and upload zip files - run: | - for file in *.zip; do - # Assuming your GitHub repository is named "username/repo" + for distro in debian ubuntu kali centos almalinux rockylinux alpine openwrt oracle archlinux; do + bash build_images.sh $distro + release_id=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ - "https://api.github.com/repos/oneclickvirt/incus_images/releases/tags/debian" \ + "https://api.github.com/repos/oneclickvirt/incus_images/releases/tags/$distro" \ | jq -r '.id') - - # Check if the asset with the same name already exists + existing_asset_id=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/oneclickvirt/incus_images/releases/$release_id/assets" \ | jq -r --arg name "$(basename "$file")" '.[] | select(.name == $name) | .id') - + if [ -n "$existing_asset_id" ]; then - # Delete existing asset with the same name curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ "https://api.github.com/repos/oneclickvirt/incus_images/releases/assets/$existing_asset_id" fi - - # Upload the new asset - echo "Uploading $file to release..." - curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -H "Content-Type: application/zip" \ - --data-binary @"$file" \ - "https://uploads.github.com/repos/oneclickvirt/incus_images/releases/$release_id/assets?name=$(basename "$file")" + + for file in *.zip; do + echo "\nUploading $file to release..." + curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Content-Type: application/zip" \ + --data-binary @"$file" \ + "https://uploads.github.com/repos/oneclickvirt/incus_images/releases/$release_id/assets?name=$(basename "$file")" + done done +