Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions .github/workflows/email-test2.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

on: [ pull_request, push ]
on: [ pull_request ]

permissions:
checks: write
Expand All @@ -10,8 +10,29 @@ jobs:
runs-on: [ self-hosted ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: foobar
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo $GITHUB_CONTEXT

run: echo $GITHUB_CONTEXT | jq
- run: git log --pretty=format:%ae | awk '/<pattern>/ && !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 }}"
- run: |
curl -L \
-H "Accept: application/vnd.github+json" \
-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 }}
- run: ls -lart && pwd && ls -lart ../ && ls -lart ../../
- run: git status
- run: python3 ../get-email/main.py
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
34 changes: 20 additions & 14 deletions get-email/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,41 @@
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")
commit = repo.get_commit(context.sha)
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
Expand Down Expand Up @@ -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__":
Expand Down