Get the branch or tag ref on delete

Is it possible to get the branch name or tag ref on delete?

on:
  delete

jobs:
  foo:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - run: echo ${GITHUB_REF}

As per the docs, $GITHUB_REF resolves to the “default branch”, which in my case is master. I’m struggling to see how returning the default branch is more useful than resolving the actual branch or tag ref that was deleted.

Is there any way to get the deleted branch name?

The event payload for delete has this infoarmtion https://developer.github.com/v3/activity/events/types/#deleteevent.

You can use the github context to access data in that payload https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#github-context

2 Likes

Just to add to this for people like me who didn’t know how to access the ref and ref_type properties for the event this is how you do it in the yaml:

- name: Hello
  run: echo "${{ github.event.ref }} - ${{ github.event.ref_type }}"
1 Like