-
Notifications
You must be signed in to change notification settings - Fork 33
33 lines (29 loc) · 1.03 KB
/
delete.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Removes Docker images belonging to feature branches when the feature branch is deleted
name: Branch Delete
on:
delete:
branches:
- '*'
jobs:
delete-branch-docker-image:
runs-on: ubuntu-latest
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get deleted branch name
id: get_branch_name
run: |
# Use jq to extract the branch name from the event payload
BRANCH=$(cat ${{ github.event_path }} | jq --raw-output '.ref' | sed 's/refs\/heads\///')
# Convert branch name to lowercase
BRANCH_NAME=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]')
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Remove Docker image
uses: dataaxiom/[email protected]
with:
delete-tags: ${{ env.BRANCH_NAME }}
token: ${{ secrets.GITHUB_TOKEN }}