oralce x86_64 #816
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: oralce x86_64 | |
| on: | |
| schedule: | |
| - cron: '0 9 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| oralce_x86_64_images: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: check path | |
| run: | | |
| pwd | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "daily-update" | |
| git config --global user.email "tg@spiritlhl.top" | |
| - name: Build and Upload Images | |
| run: | | |
| distros=("oracle") | |
| for distro in "${distros[@]}"; do | |
| zip_name_list=($(bash build_images.sh $distro false x86_64 | tail -n 1)) | |
| release_json=$(curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/oneclickvirt/lxc_amd64_images/releases/tags/$distro") | |
| release_id=$(echo "$release_json" | jq -r '.id // empty') | |
| if ! [[ "$release_id" =~ ^[0-9]+$ ]]; then | |
| echo "Skip $distro: release tag missing or API error" | |
| echo "$release_json" | jq -r '.message // empty' | |
| continue | |
| fi | |
| echo "Building $distro and packge zips" | |
| bash build_images.sh $distro true x86_64 | |
| for file in "${zip_name_list[@]}"; do | |
| if [ -f "$file" ] && [ $(stat -c %s "$file") -gt 10485760 ]; then | |
| echo "Checking if $file already exists in release..." | |
| assets_json=$(curl -s -H "Accept: application/vnd.github.v3+json" \ | |
| "https://api.github.com/repos/oneclickvirt/lxc_amd64_images/releases/$release_id/assets") | |
| existing_asset_id=$(echo "$assets_json" | jq -r --arg name "$(basename "$file")" 'if type == "array" then (map(select(.name == $name))[0].id // empty) else empty end') | |
| if [ -n "$existing_asset_id" ]; then | |
| echo "Asset $file already exists in release, deleting existing asset..." | |
| delete_response=$(curl -s -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/oneclickvirt/lxc_amd64_images/releases/assets/$existing_asset_id") | |
| echo "$delete_response" | |
| if [ $? -eq 0 ] && ! echo "$delete_response" | grep -q "error"; then | |
| echo "Existing asset deleted successfully." | |
| else | |
| echo "Failed to delete existing asset. Skipping file upload..." | |
| rm -rf $file | |
| continue | |
| fi | |
| else | |
| echo "No $file file." | |
| fi | |
| echo "Uploading $file to release..." | |
| curl -f -s -X POST \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Content-Type: application/octet-stream" \ | |
| --max-time 3600 \ | |
| -T "$file" \ | |
| "https://uploads.github.com/repos/oneclickvirt/lxc_amd64_images/releases/$release_id/assets?name=$(basename "$file")" | |
| rm -rf $file | |
| else | |
| echo "No $file or less than 10 MB" | |
| fi | |
| done | |
| done | |