diff --git a/.github/workflows/release-digital-ocean.yml b/.github/workflows/release-digital-ocean.yml index a0d0854..49ba66a 100644 --- a/.github/workflows/release-digital-ocean.yml +++ b/.github/workflows/release-digital-ocean.yml @@ -44,3 +44,22 @@ jobs: DIGITALOCEAN_IMG_VERSION: ${{ steps.set-version.outputs.version }} working-directory: ./DigitalOceanMarketplace run: packer build marketplace-image.json + + - name: Digital Ocean Image Cleanup + env: + DIGITALOCEAN_TOKEN: ${{ steps.retrieve-secrets.outputs.digital-ocean-api-key }} + working-directory: ./DigitalOceanMarketplace + if: | + github.ref != 'refs/heads/master' || + github.ref != 'refs/head/hotfix' || + github.ref != 'refs/heads/rc' + run: | + brew install doctl + # Authenticate to Digital Ocean. + doctl auth init -t $DIGITALOCEAN_TOKEN + + # Get the ID from the snapshot build. + DO_ARTIFACT=$(jq -r '.builds[-1].artifact_id' manifest.json | cut -d ":" -f2) + + # Force remove the snapshot + doctl compute image delete $DO_ARTIFACT -f diff --git a/DigitalOceanMarketplace/marketplace-image.json b/DigitalOceanMarketplace/marketplace-image.json index dcb7bfe..e3a20fc 100644 --- a/DigitalOceanMarketplace/marketplace-image.json +++ b/DigitalOceanMarketplace/marketplace-image.json @@ -82,5 +82,12 @@ "scripts/99-img-check.sh" ] } + ], + "post-processors": [ + { + "type": "manifest", + "output": "manifest.json", + "strip_path": true + } ] }