From 8fd6403582e5a6da3683c40f36a67ccb488b8ec0 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:06:54 -0500 Subject: [PATCH 01/15] abc From 755111806c12a184123be33005fa138648c8e681 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:12:08 -0500 Subject: [PATCH 02/15] changes --- .github/workflows/email-test2.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index eaec5c8..b4e5ba4 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -13,5 +13,9 @@ jobs: - name: foobar env: GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo $GITHUB_CONTEXT - + run: echo $GITHUB_CONTEXT | jq + - run: git log --pretty=format:%ae | awk '// && !line{line=$0} END{print line}' + - name: Get PR Author Email Address + run: | + echo "The name of the pusher: ${{ github.event.pusher.name }}" + echo "The email of the pusher: ${{ github.event.pusher.email }}" From b7163360c908968d2b79e9fb23391eea06ca0c23 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:18:52 -0500 Subject: [PATCH 03/15] changes --- .github/workflows/email-test2.yaml | 2 ++ docker/Dockerfile | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index b4e5ba4..3bec528 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -10,6 +10,8 @@ jobs: runs-on: [ self-hosted ] steps: - uses: actions/checkout@v4 + with: + depth: 100 - name: foobar env: GITHUB_CONTEXT: ${{ toJson(github) }} diff --git a/docker/Dockerfile b/docker/Dockerfile index a8dd2c6..ae65479 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -14,3 +14,4 @@ RUN python3 -m venv ~/venv && echo "source ~/venv/bin/activate" >> ~/.bashrc RUN . ~/venv/bin/activate && python3 -m pip install --upgrade pip && python3 -m pip install -r /tmp/requirements.txt +RUN sudo apt-get update && sudo apt-get install -y jq From e40fceeaf4f4e0a968b9c42ee0d2e42a0523ef33 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:19:39 -0500 Subject: [PATCH 04/15] changes --- .github/workflows/email-test2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index 3bec528..6fdfe4c 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - depth: 100 + fetch-depth: 100 - name: foobar env: GITHUB_CONTEXT: ${{ toJson(github) }} From 742d91962051fe381bc2740b1d5d35491889d3fe Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:22:56 -0500 Subject: [PATCH 05/15] changes --- .github/workflows/email-test2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index 6fdfe4c..662a8c6 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-depth: 100 + sparse-checkout: false - name: foobar env: GITHUB_CONTEXT: ${{ toJson(github) }} From 1fbecf473460fafc88cb2ef275e837ce872829ae Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:23:06 -0500 Subject: [PATCH 06/15] changes --- .github/workflows/email-test2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index 662a8c6..3e4e2ea 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -1,5 +1,5 @@ -on: [ pull_request, push ] +on: [ pull_request ] permissions: checks: write From d21131e7dfc46d5cc8bb7aca373b1e3a45aec707 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:31:30 -0500 Subject: [PATCH 07/15] changes --- .github/workflows/email-test2.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index 3e4e2ea..459c6ee 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -21,3 +21,9 @@ jobs: run: | echo "The name of the pusher: ${{ github.event.pusher.name }}" echo "The email of the pusher: ${{ github.event.pusher.email }}" + - run: |- + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/users/${{ github.actor }} From 5253dbf610ac8a83c166fdf33ab603da1a68c6bf Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:32:31 -0500 Subject: [PATCH 08/15] changes --- .github/workflows/email-test2.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index 459c6ee..d61a376 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -21,9 +21,9 @@ jobs: run: | echo "The name of the pusher: ${{ github.event.pusher.name }}" echo "The email of the pusher: ${{ github.event.pusher.email }}" - - run: |- + - run: | curl -L \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Authorization: $GITHUB_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/${{ github.actor }} From 89000f64e64973e9156da7aaa18f2dac11f5a604 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:39:18 -0500 Subject: [PATCH 09/15] changes --- .github/workflows/email-test2.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index d61a376..b16b281 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -27,3 +27,9 @@ jobs: -H "Authorization: $GITHUB_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/users/${{ github.actor }} + - run: | + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: $GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + ${{ github.event.pull_request._links.commits.href }} From c9af421e7ab867c04c0499027a271d6b194c7c3a Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:49:13 -0500 Subject: [PATCH 10/15] changes --- .github/workflows/email-test2.yaml | 1 + get-email/main.py | 34 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index b16b281..4a85541 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -33,3 +33,4 @@ jobs: -H "Authorization: $GITHUB_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ ${{ github.event.pull_request._links.commits.href }} + - run: python3 ./get-email/main.py diff --git a/get-email/main.py b/get-email/main.py index 7198bf5..9f7626f 100644 --- a/get-email/main.py +++ b/get-email/main.py @@ -7,15 +7,20 @@ from actions_toolkit.github import Context from github import Github from pydantic import BaseModel, Field +import requests import rich + # Create Github instance with provided token github_token = os.environ["GITHUB_TOKEN"] github = Github(github_token) + # Get current context (GitHub Actions context) context = Context() +import rich +rich.inspect(context, methods=True) # Fetch the repository information repo = github.get_repo("efcs/action") @@ -23,6 +28,20 @@ rich.inspect(commit) rich.print(commit) +def get_commits(): + headers = { + 'Accept': 'application/vnd.github+json', + 'Authorization': os.environ['GITHUB_TOKEN'], + 'X-GitHub-Api-Version': '2022-11-28' + } + + url = os.environ['PULL_REQUEST_COMMITS_HREF'] + + response = requests.get(url, headers=headers) + rich.print(response) + response.raise_for_status() + return response.json() + class Annotation(BaseModel): path: str @@ -52,20 +71,7 @@ class CheckRun(BaseModel): def main(): rich.print(context) - ''' - check_run = repo.create_check_run( - name="Libc++ Test Suite", - head_sha=context.sha, - status="completed", - conclusion=conclusion, - output={ - "title": "Check Run Output", - "summary": f"{len(annotations)} tests failed.", - "annotations": annotations - }, - ) - rich.print(check_run) - ''' + get_commits() if __name__ == "__main__": From 05cea178578f0dedcd11636a9fb9a2a02cb564b5 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:51:11 -0500 Subject: [PATCH 11/15] changes --- .github/workflows/email-test2.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index 4a85541..b65c58a 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -33,4 +33,5 @@ jobs: -H "Authorization: $GITHUB_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ ${{ github.event.pull_request._links.commits.href }} + - run: ls - run: python3 ./get-email/main.py From 8d41203efc807b1ff7be8e044c3fffc2bb70bfc5 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:52:02 -0500 Subject: [PATCH 12/15] changes --- .github/workflows/email-test2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index b65c58a..baa0515 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -33,5 +33,5 @@ jobs: -H "Authorization: $GITHUB_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ ${{ github.event.pull_request._links.commits.href }} - - run: ls + - run: ls -lart && pwd && ls -lart ../ && ls -lart ../../ - run: python3 ./get-email/main.py From bb260e8c75be45e55accb3968d9c6e7a44285a90 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:55:20 -0500 Subject: [PATCH 13/15] changes --- .github/workflows/email-test2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index baa0515..60fc3b0 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -34,4 +34,4 @@ jobs: -H "X-GitHub-Api-Version: 2022-11-28" \ ${{ github.event.pull_request._links.commits.href }} - run: ls -lart && pwd && ls -lart ../ && ls -lart ../../ - - run: python3 ./get-email/main.py + - run: python3 ../action/get-email/main.py From 4734c8634c6d3b2db70adbbd48836568b42aa354 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:58:39 -0500 Subject: [PATCH 14/15] changes --- .github/workflows/email-test2.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index 60fc3b0..d2ebfb6 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -34,4 +34,5 @@ jobs: -H "X-GitHub-Api-Version: 2022-11-28" \ ${{ github.event.pull_request._links.commits.href }} - run: ls -lart && pwd && ls -lart ../ && ls -lart ../../ - - run: python3 ../action/get-email/main.py + - run: git status + - run: python3 ../get-email/main.py From dc47cfb648090fd6245530e0c0d98f8e0e715044 Mon Sep 17 00:00:00 2001 From: eric <1176427+EricWF@users.noreply.github.com> Date: Tue, 28 Nov 2023 10:00:36 -0500 Subject: [PATCH 15/15] changes --- .github/workflows/email-test2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/email-test2.yaml b/.github/workflows/email-test2.yaml index d2ebfb6..0e90c1b 100644 --- a/.github/workflows/email-test2.yaml +++ b/.github/workflows/email-test2.yaml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - sparse-checkout: false + fetch-depth: 0 - name: foobar env: GITHUB_CONTEXT: ${{ toJson(github) }}