|
8 | 8 | on-merge: |
9 | 9 | runs-on: ubuntu-latest |
10 | 10 | if: ${{ github.event.pull_request.merged == true }} |
| 11 | + permissions: |
| 12 | + contents: read |
11 | 13 | steps: |
12 | 14 | - name: Get Pull Request Data |
13 | 15 | id: get-pr-data |
14 | | - env: |
15 | | - PULL_REQUEST_OWNER: ${{ github.event.pull_request.user.login }} |
16 | | - PULL_REQUEST_LABELS: ${{ join(github.event.pull_request.labels.*.name, ', ') }} |
17 | | - REPOSITORY_NAME: ${{ github.event.repository.name }} |
18 | | - REPOSITORY_URL: ${{ github.event.repository.html_url }} |
19 | 16 | run: | |
20 | | - echo "::set-output name=owner::$PULL_REQUEST_OWNER" |
21 | | - echo "::set-output name=labels::$PULL_REQUEST_LABELS" |
22 | | - echo "::set-output name=repo_name::$REPOSITORY_NAME" |
23 | | - echo "::set-output name=repo_url::$REPOSITORY_URL" |
| 17 | + echo "owner=${{ github.event.pull_request.user.login }}" >> $GITHUB_OUTPUT |
| 18 | + echo "labels=${{ join(github.event.pull_request.labels.*.name, ', ') }}" >> $GITHUB_OUTPUT |
| 19 | + echo "repo_name=${{ github.event.repository.name }}" >> $GITHUB_OUTPUT |
| 20 | + echo "repo_url=${{ github.event.repository.html_url }}" >> $GITHUB_OUTPUT |
24 | 21 |
|
25 | 22 | - name: Send Data to API |
26 | 23 | env: |
27 | 24 | API_URL: https://opcode.gymkhana.iiitbh.ac.in/api/prmerged |
28 | 25 | API_AUTH_TOKEN: ${{ secrets.API_AUTH_TOKEN }} |
| 26 | + OWNER: ${{ steps.get-pr-data.outputs.owner }} |
| 27 | + LABELS: ${{ steps.get-pr-data.outputs.labels }} |
| 28 | + REPO_NAME: ${{ steps.get-pr-data.outputs.repo_name }} |
| 29 | + REPO_URL: ${{ steps.get-pr-data.outputs.repo_url }} |
29 | 30 | run: | |
30 | | - payload=$(echo '{"owner":"${{ steps.get-pr-data.outputs.owner }}","labels":"${{ steps.get-pr-data.outputs.labels }}","repository_name":"${{ steps.get-pr-data.outputs.repo_name }}","repository_url":"${{ steps.get-pr-data.outputs.repo_url }}"}') |
31 | | - curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $API_AUTH_TOKEN" -d "$payload" "$API_URL" |
| 31 | + payload=$(jq -n \ |
| 32 | + --arg owner "$OWNER" \ |
| 33 | + --arg labels "$LABELS" \ |
| 34 | + --arg repo_name "$REPO_NAME" \ |
| 35 | + --arg repo_url "$REPO_URL" \ |
| 36 | + '{owner: $owner, labels: $labels, repository_name: $repo_name, repository_url: $repo_url}') |
| 37 | + |
| 38 | + curl -X POST \ |
| 39 | + -H "Content-Type: application/json" \ |
| 40 | + -H "Authorization: Bearer $API_AUTH_TOKEN" \ |
| 41 | + -d "$payload" \ |
| 42 | + "$API_URL" |
0 commit comments