Clean up feature branches #5
This file contains 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: Clean up feature branches | |
on: | |
delete: | |
jobs: | |
delete: | |
if: github.event.ref_type == 'branch' && startsWith(github.event.ref, 'feature/') | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
image-name: | |
[ | |
tna-python, | |
tna-python-root, | |
tna-python-django, | |
tna-python-django-root, | |
tna-python-dev, | |
] | |
steps: | |
- name: Prepare image tag | |
run: | | |
IMAGE_ID=${{ matrix.image-name }} | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
echo "IMAGE_ID=$IMAGE_ID" >> "$GITHUB_ENV" | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.event.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
echo "TAG=$VERSION" >> "$GITHUB_ENV" | |
- name: Output image tag | |
run: echo "Clean up Docker image ${{ env.IMAGE_ID }}:${{ env.TAG }}" | |
- name: Delete image | |
uses: bots-house/[email protected] | |
with: | |
owner: ${{ github.repository_owner }} | |
name: ${{ env.IMAGE_ID }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ env.TAG }} |