|
| 1 | +name: Add Issue to Project when assigned |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: |
| 6 | + - assigned |
| 7 | + - labeled |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_user_list: |
| 11 | + name: Get yaml config of GS users |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Get user-mapping |
| 15 | + run: | |
| 16 | + mkdir -p artifacts |
| 17 | + wget --header "Authorization: token ${{ secrets.ISSUE_AUTOMATION }}" \ |
| 18 | + -O artifacts/users.yaml \ |
| 19 | + https://raw.githubusercontent.com/giantswarm/github/main/tools/issue-automation/user-mapping.yaml |
| 20 | + - name: Upload Artifact |
| 21 | + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 |
| 22 | + with: |
| 23 | + name: users |
| 24 | + path: artifacts/users.yaml |
| 25 | + retention-days: 1 |
| 26 | + - name: Get label-mapping |
| 27 | + run: | |
| 28 | + mkdir -p artifacts |
| 29 | + wget --header "Authorization: token ${{ secrets.ISSUE_AUTOMATION }}" \ |
| 30 | + -O artifacts/labels.yaml \ |
| 31 | + https://raw.githubusercontent.com/giantswarm/github/main/tools/issue-automation/label-mapping.yaml |
| 32 | + - name: Upload Artifact |
| 33 | + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 |
| 34 | + with: |
| 35 | + name: labels |
| 36 | + path: artifacts/labels.yaml |
| 37 | + retention-days: 1 |
| 38 | + |
| 39 | + add_to_personal_board: |
| 40 | + name: Add issue to personal board |
| 41 | + runs-on: ubuntu-latest |
| 42 | + needs: build_user_list |
| 43 | + if: github.event.action == 'assigned' |
| 44 | + steps: |
| 45 | + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 46 | + id: download-users |
| 47 | + with: |
| 48 | + name: users |
| 49 | + - name: Find personal board based on user names |
| 50 | + run: | |
| 51 | + event_assignee=$(cat $GITHUB_EVENT_PATH | jq -r .assignee.login | tr '[:upper:]' '[:lower:]') |
| 52 | + echo "Issue assigned to: ${event_assignee}" |
| 53 | +
|
| 54 | + BOARD=($(cat ${{steps.download-users.outputs.download-path}}/users.yaml | tr '[:upper:]' '[:lower:]' | yq ".${event_assignee}.personalboard")) |
| 55 | + echo "Personal board URL: ${BOARD}" |
| 56 | +
|
| 57 | + echo "BOARD=${BOARD}" >> $GITHUB_ENV |
| 58 | + - name: Add issue to personal board |
| 59 | + if: ${{ env.BOARD != 'null' && env.BOARD != '' && env.BOARD != null }} |
| 60 | + uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2 |
| 61 | + with: |
| 62 | + project-url: ${{ env.BOARD }} |
| 63 | + github-token: ${{ secrets.ISSUE_AUTOMATION }} |
| 64 | + |
| 65 | + add_to_team_board: |
| 66 | + name: Add issue to team board |
| 67 | + runs-on: ubuntu-latest |
| 68 | + needs: build_user_list |
| 69 | + if: github.event.action == 'labeled' |
| 70 | + steps: |
| 71 | + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 72 | + id: download-labels |
| 73 | + with: |
| 74 | + name: labels |
| 75 | + - name: Find team board based on label |
| 76 | + run: | |
| 77 | + event_label=$(cat $GITHUB_EVENT_PATH | jq -r .label.name | tr '[:upper:]' '[:lower:]') |
| 78 | + echo "Issue labelled with: ${event_label}" |
| 79 | +
|
| 80 | + BOARD=($(cat ${{steps.download-labels.outputs.download-path}}/labels.yaml | tr '[:upper:]' '[:lower:]' | yq ".[\"${event_label}\"].projectboard")) |
| 81 | + echo "Team board URL: ${BOARD}" |
| 82 | +
|
| 83 | + echo "BOARD=${BOARD}" >> $GITHUB_ENV |
| 84 | + - name: Add issue to team board |
| 85 | + if: ${{ env.BOARD != 'null' && env.BOARD != '' && env.BOARD != null }} |
| 86 | + uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2 |
| 87 | + with: |
| 88 | + project-url: ${{ env.BOARD }} |
| 89 | + github-token: ${{ secrets.ISSUE_AUTOMATION }} |
0 commit comments