Labeling issues

I have a test repo. and I want do the following with my issues: when I remove some X issue from any milestone label [NEEDS MILESTONE] adds. The problem is I don’t know how to write .yml file to it. I’m  beginner in GitHub actions.

Hi @alvin-seville ,

Glad to see you in Github Community Forum!

You can use ‘issues’ with type ‘demilestoned’ to trigger the workflow(please use in ‘master’ branch), and then use rest api to add a ‘Needs Milestone’ label for the issue. Please check below docs for more detail.

https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#issues-event-issues

https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue

Code sample as below:

name: milestone
on:
  issues:
    types: demilestoned
jobs:
  demilestoned:
    runs-on: [ubuntu-latest]
    steps:
      - name: get issue
        run: |
          echo ${{ github.event.issue.url }}
      - name: add label
        run: |
          curl -v -u admin:${{ secrets.GITHUB_TOKEN }} -H "Accept: application/vnd.github.antiope-preview+json" -d '{"labels": ["Needs Milestone"]}' ${{ github.event.issue.url }}/labels

Labelissue.png

1 Like