|
| 1 | +name: fedora x86_64 |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '30 14 * * *' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + fedora_x86_64_images: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v2 |
| 13 | + |
| 14 | + - name: check path |
| 15 | + run: | |
| 16 | + pwd |
| 17 | +
|
| 18 | + - name: Configure Git |
| 19 | + run: | |
| 20 | + git config --global user.name "daily-update" |
| 21 | + git config --global user.email "tg@spiritlhl.top" |
| 22 | + |
| 23 | + - name: Build and Upload Images |
| 24 | + run: | |
| 25 | + distros=("fedora") |
| 26 | + for distro in "${distros[@]}"; do |
| 27 | + zip_name_list=($(bash build_images.sh $distro false x86_64 | tail -n 1)) |
| 28 | + release_id=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/oneclickvirt/incus_images/releases/tags/$distro" | jq -r '.id') |
| 29 | + for file in "${zip_name_list[@]}"; do |
| 30 | + echo "Building $distro and packge zips" |
| 31 | + bash build_images.sh $distro true x86_64 |
| 32 | + if [ -f "$file" ] && [ $(stat -c %s "$file") -gt 1048576 ]; then |
| 33 | + echo "Checking if $file already exists in release..." |
| 34 | + existing_asset_id=$(curl -s -H "Accept: application/vnd.github.v3+json" \ |
| 35 | + "https://api.github.com/repos/oneclickvirt/incus_images/releases/$release_id/assets" \ |
| 36 | + | jq -r --arg name "$(basename "$file")" '.[] | select(.name == $name) | .id') |
| 37 | + if [ -n "$existing_asset_id" ]; then |
| 38 | + echo "Asset $file already exists in release, deleting existing asset..." |
| 39 | + delete_response=$(curl -s -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/incus_images/releases/assets/$existing_asset_id") |
| 40 | + echo "$delete_response" |
| 41 | + if [ $? -eq 0 ] && ! echo "$delete_response" | grep -q "error"; then |
| 42 | + echo "Existing asset deleted successfully." |
| 43 | + else |
| 44 | + echo "Failed to delete existing asset. Skipping file upload..." |
| 45 | + rm -rf $file |
| 46 | + continue |
| 47 | + fi |
| 48 | + else |
| 49 | + echo "No $file file." |
| 50 | + fi |
| 51 | + echo "Uploading $file to release..." |
| 52 | + curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ |
| 53 | + -H "Content-Type: application/zip" \ |
| 54 | + --data-binary @"$file" \ |
| 55 | + "https://uploads.github.com/repos/oneclickvirt/incus_images/releases/$release_id/assets?name=$(basename "$file")" |
| 56 | + rm -rf $file |
| 57 | + else |
| 58 | + echo "No $file or less than 10 MB" |
| 59 | + fi |
| 60 | + done |
| 61 | + done |
| 62 | + |
0 commit comments