ERROR: Error while running diskutil commands on macOS-11 Runner

When I’m trying to run this:

sudo hdiutil create -o /tmp/BigSur -size 16384m -volname BigSur -layout SPUD -fs HFS+J
sudo hdiutil attach /tmp/BigSur.dmg -noverify -mountpoint /Volumes/BigSur
sudo /Applications/Install\ macOS\ Big\ Sur.app/Contents/Resources/createinstallmedia --volume /Volumes/BigSur --nointeraction
hdiutil eject -force /Volumes/Install\ macOS\ Big\ Sur
hdiutil convert /tmp/BigSur.dmg -format UDTO -o ~/Desktop/BigSur
mv -v ~/Desktop/BigSur.cdr ~/Desktop/BigSur.iso
sudo rm -fv /tmp/BigSur.dmg

There comes an error with it’s output:

created: /tmp/BigSur.dmg
/dev/disk2          	Apple_partition_scheme         	
/dev/disk2s1        	Apple_partition_map            	
/dev/disk2s2        	Apple_HFS                      	/Volumes/BigSur
Erasing disk: 0%... 10%...
Error erasing disk error number (22, 0)
An error occurred erasing the disk.
Error: Process completed with exit code 252.

How do I fix this?

Details:
Repository: GitHub - Comp-Labs/Download-macOS: Download macOS ISO/DMG using this tool.

Another Error:

When run this:

sudo "/System/Library/PrivateFrameworks/Seeding.framework/Versions/Current/Resources/seedutil" enroll DeveloperSeed
  sleep 5
  softwareupdate --fetch-full-installer --full-installer-version 13.0

Getting This:

2022-06-23 13:54:26.930 seedutil[871:5887] audiences result was 0
Enrolling...
Program: 2
Build is seed: NO
CatalogURL: https://swscan.apple.com/content/catalogs/others/index-10.16seed-10.16-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz
NSShowFeedbackMenu: YES
DisableSeedOptOut: NO
Asset Audience: ca60afc6-5954-46fd-8cb9-60dde6ac39fd
Scanning for 13.0 installer
Install failed with error: Update not found 
Error: Process completed with exit code 1.

Both these errors I don’t know why only happen sometimes like a unknown miracle. Sometimes it works, sometimes it does not.