Skip to content

Delete Snapshot on Branch Deletion #100

Delete Snapshot on Branch Deletion

Delete Snapshot on Branch Deletion #100

name: Delete Snapshot on Branch Deletion
on:
delete:
branches:
- "**"
jobs:
delete-snapshot:
runs-on: ubuntu-latest
steps:
- name: Retrieve post upgrade snapshot generator binary
run: |
POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION=v0.2.5
DOWNLOAD_URL=https://github.com/elys-network/post-upgrade-snapshot-generator/releases/download/${POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION}/post-upgrade-snapshot-generator-${POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION}-linux-amd64
POST_UPGRADE_SNAPSHOT_GENERATOR_PATH=/tmp/post-upgrade-snapshot-generator-${POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION}
curl -L $DOWNLOAD_URL -o $POST_UPGRADE_SNAPSHOT_GENERATOR_PATH && chmod +x $POST_UPGRADE_SNAPSHOT_GENERATOR_PATH
echo "POST_UPGRADE_SNAPSHOT_GENERATOR_PATH=$POST_UPGRADE_SNAPSHOT_GENERATOR_PATH" >> $GITHUB_ENV
- name: Run delete-snapshot
env:
R2_ACCESS_KEY: ${{ secrets.R2_ACCESS_KEY }}
R2_SECRET_KEY: ${{ secrets.R2_SECRET_KEY }}
R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }}
R2_BUCKET_NAME: ${{ secrets.R2_BUCKET_NAME }}
run: |
SANITIZED_EVENT_REF=${{ github.event.ref }}
SANITIZED_EVENT_REF=$(echo "$SANITIZED_EVENT_REF" | sed 's|refs/heads/||; s|/|_|g')
${POST_UPGRADE_SNAPSHOT_GENERATOR_PATH} delete-snapshot "$SANITIZED_EVENT_REF"