|
1 | | -name: Notify Teams on new PR |
| 1 | +name: Send PR events to Power Automate |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - types: [opened] |
| 4 | + pull_request_target: |
| 5 | + types: [opened, reopened, ready_for_review] |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - notify: |
| 8 | + notify-power-automate: |
9 | 9 | runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + contents: read |
| 12 | + |
10 | 13 | steps: |
11 | | - - name: Post card to Microsoft Teams |
| 14 | + - name: Prepare and send PR event to Power Automate |
12 | 15 | env: |
13 | | - TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} |
| 16 | + FLOW_URL: ${{ secrets.FLOW_WEBHOOK_URL }} |
14 | 17 | run: | |
15 | | - payload=$(cat <<'JSON' |
16 | | - { |
17 | | - "@type": "MessageCard", |
18 | | - "@context": "http://schema.org/extensions", |
19 | | - "summary": "Neuer Pull Request", |
20 | | - "themeColor": "0076D7", |
21 | | - "title": "Neuer PR: #${{ github.event.pull_request.number }} – ${{ github.event.pull_request.title }}", |
22 | | - "sections": [{ |
23 | | - "activityTitle": "[${{ github.event.pull_request.user.login }}](${{ github.event.pull_request.user.html_url }}) hat einen Pull Request eröffnet", |
24 | | - "facts": [ |
25 | | - {"name": "Repository", "value": "${{ github.repository }}"}, |
26 | | - {"name": "Branch", "value": "${{ github.event.pull_request.head.ref }} → ${{ github.event.pull_request.base.ref }}"}, |
27 | | - {"name": "Beschreibung", "value": "${{ github.event.pull_request.body }}"} |
28 | | - ], |
29 | | - "markdown": true |
30 | | - }], |
31 | | - "potentialAction": [{ |
32 | | - "@type": "OpenUri", |
33 | | - "name": "PR öffnen", |
34 | | - "targets": [{"os": "default", "uri": "${{ github.event.pull_request.html_url }}"}] |
35 | | - }] |
36 | | - } |
37 | | - JSON |
38 | | - ) |
| 18 | + set -euo pipefail |
| 19 | +
|
| 20 | + echo "→ Sending pull_request event to Power Automate..." |
39 | 21 | curl -sS -X POST \ |
40 | 22 | -H "Content-Type: application/json" \ |
41 | | - -d "$payload" \ |
42 | | - "$TEAMS_WEBHOOK_URL" |
| 23 | + -H "X-GitHub-Event: pull_request" \ |
| 24 | + -H "X-Repository: $GITHUB_REPOSITORY" \ |
| 25 | + --data-binary "@$GITHUB_EVENT_PATH" \ |
| 26 | + "$FLOW_URL" |
| 27 | +
|
| 28 | + echo "✅ Event sent for PR #${{ github.event.number }} in ${{ github.repository }}" |
0 commit comments