Help with github actions

if I have a file in my repository with at line 1 :

“name:”

and if I commit the change :

“name: Octocat”

I would like at pull-request to automatically give it

a label : “named”

and a Milestone : “identity”

and check the box : “name the file” in my project.

how do i perform that in an easy wysiwyg human friendly way?

Hi @ojedavidea,

Glad to see you in Github Community Forum!

Image you have base branch B1, and compared branch B2, create PR from B2 to B1.
In the workflow yaml:

name: PR1
on: [pull_request]
jobs:
  PR1:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: check the value for name
        run: |
           .....               # check the name value, if it's not 'Octocat', exit 1 to fail the workflow.

      - name: add label and milestone    # will be executed when name value is correct
        run: |
          curl --request PATCH \
            --url ${{ github.event.pull_request.issue_url }} \
            --header 'authorization: token ${{ secrets.GITHUB_TOKEN }}' \
            --data '{"milestone": 1, "labels": [ "bug" ]}'      # 1 is the milestone number

Please refer to the rest api doc here for more details. And my workflow sample here: https://github.com/weide-zhou/Ticket2/runs/848581984?check_suite_focus=true#step:4:1
image

Regarding the checkbox in the project, it’s in the note content of the card, you need to use rest api here to update the card note, add x to [ ] to select the checkbox.

Thanks.

Hi @ojedavidea,

The check step is skipped on my sample code, please check my comment. Error occurs due to ‘…’.

The check step is due to how you evalue the changes, if you only monitor the changes on ‘testname2’ file, you can use below code:

      - name: checkout
        uses: actions/checkout@v2
      - name: check value and set label milestone
        run: |
          STR="name: Octocat"
          if [ `grep -c "$STR" testname2` -ne '0' ];then
             echo "Found"                                                # find the string in testname2 file, start to add label and milestone
             curl --request PATCH \
            --url ${{ github.event.pull_request.issue_url }} \
            --header 'authorization: token ${{ secrets.GITHUB_TOKEN }}' \
            --data '{"milestone": 1, "labels": [ "bug" ]}'
          else
             echo "NotFound"
          fi

my workflow: https://github.com/weide-zhou/Ticket2/runs/853269578?check_suite_focus=true
my pull request: https://github.com/weide-zhou/Ticket2/pull/19

Thanks.