-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (44 loc) · 1.5 KB
/
pull_request_count.yml
File metadata and controls
51 lines (44 loc) · 1.5 KB
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
name: Count Open PRs
on:
#Scheduled Job, commented to not make it work
#schedule:
#- cron: '0 0 * * *' # This cron schedule triggers the workflow at midnight every day
# For manual testing purposes
workflow_dispatch:
#When a new pull request is opened, port needs to be updated
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
count_open_prs:
runs-on: ubuntu-latest
steps:
- name: Check Out Repository
uses: actions/checkout@v2
- name: Count Open PRs
id: pr_count
run: |
# Fetching all PR through API
PRS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls?state=open")
# Parse the JSON response and count the open PRs
PR_COUNT=$(echo "$PRS" | jq length)
echo "Number of Open Pull Requests: $PR_COUNT"
# Store the PR count as an output
echo "::set-output name=pr_count::$PR_COUNT"
# Update entity at port
- name: Update port
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.CLIENT_ID }}
clientSecret: ${{ secrets.CLIENT_SECRET }}
operation: UPSERT
identifier: FlameBot
blueprint: microservice
properties: |
{
"pr_count": ${{ steps.pr_count.outputs.pr_count }}
}