Skip to content

Delete Snapshot on Branch Deletion #493

Delete Snapshot on Branch Deletion

Delete Snapshot on Branch Deletion #493

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.6.1
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_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
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"