๐Ÿ“ฆ wagoodman / project-add-test

๐Ÿ“„ reusable.yaml ยท 72 lines
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72name: Actually add to project

on: 
  workflow_call:

    inputs:
      project_url:
        default: https://github.com/users/wagoodman/projects/1
        description: "The URL of the project to add the issue or PR to"
        type: string

      users:
        default: '["wagoodman"]'
        description: "JSON list as string of users to ignore"
        type: string

    secrets:
      token:
        description: "The classic GitHub token (with project access) to use for authentication"
        required: true


jobs:

  show-info:
    name: Show issue or PR event info
    runs-on: ubuntu-latest
    steps:
      - name: Show event info
        run: |
          echo "Event Name: ${{ github.event_name }}"
          echo "Number: ${{ github.event.issue.number }}"
          echo "Issue Author: '${{ github.event.issue.user.login }}' is-oss-user=${{ !contains(fromJson(  inputs.users ), github.event.issue.user.login) && github.event.issue.user.login != '' }}"
          echo "PR Author: '${{ github.event.pull_request.user.login }}' is-oss-user=${{ !contains(fromJson( inputs.users ), github.event.pull_request.user.login) && github.event.pull_request.user.login != '' }}"
          echo "Avoid users: ${{ inputs.users }}"


  add-issue-to-board:
    name: Add issue to the community board
    if: github.event_name == 'issues' && !contains(fromJson( ${{ inputs.users }} ), github.event.issue.user.login)
    runs-on: ubuntu-latest
    steps:
      - name: Show event info
        run: |
          echo "Event Name: ${{ github.event_name }}"
          echo "Number: ${{ github.event.issue.number }}"
          echo "Issue Author: ${{ github.event.issue.user.login }}"

      - uses: actions/add-to-project@v0.5.0
        with:
          project-url: ${{ inputs.project_url }}
          github-token: ${{ secrets.token }}
          labeled: bug, enhancement
          label-operator: OR

  add-pr-to-board:
    name: Add PR to the community board
    if: github.event_name == 'pull_request' && !contains(fromJson( ${{ inputs.users }} ), github.event.pull_request.user.login)
    runs-on: ubuntu-latest
    steps:
      - name: Show event info
        run: |
          echo "Event Name: ${{ github.event_name }}"
          echo "Number: ${{ github.event.issue.number }}"
          echo "PR Author: ${{ github.event.pull_request.user.login }}"
  
      - uses: actions/add-to-project@v0.5.0
        with:
          project-url: ${{ inputs.project_url }}
          github-token: ${{ secrets.token }}
          labeled: bug, enhancement
          label-operator: OR