Skip to content
This repository has been archived by the owner on Aug 25, 2024. It is now read-only.

Commit

Permalink
ci: alice async comms: Dump Engineering Log Entries
Browse files Browse the repository at this point in the history
  • Loading branch information
pdxjohnny authored and aliceoa-intel committed Jan 5, 2024
1 parent 434f822 commit 6e5462b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/alice_async_comms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name: "Alice: Async Comms"
# - https://github.com/Textualize/rich/blob/84e628655a2981ee90413ca3f35001ec3954161d/.github/workflows/readmechanged.yml#L1-L24 (MIT)

on:
workflow_dispatch: null
schedule:
- cron: '0 6 * * *'

Expand All @@ -20,8 +21,29 @@ jobs:
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
with:
egress-policy: audit

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Dump engineering log entries
id: dump-logs
env:
GH_TOKEN: ${{ github.token }}
TITLE: "docs: discussions: Alice Engineering Comms"
DISCUSSION_NUMBER: 1406
run: |
set -xeuo pipefail
python -m pip install -U pip setuptools wheel
python -m pip install aiohttp
python -u scripts/dump_discussion.py --token "$GH_TOKEN" --owner $(echo $GITHUB_REPOSITORY | sed -e 's/\/.*//g') --repo $(echo $GITHUB_REPOSITORY | sed -e 's/.*\///g') --discussion-number $DISCUSSION_NUMBER | tee /dev/stderr | sed -e 's/\/tree\/alice/\/tree\/main/g' -e 's/\/blob\/alice/\/blob\/main/g' | python -u scripts/discussion_dump_to_markdown.py
echo "msg=$TITLE: $(date -Iseconds)" >> $GITHUB_OUTPUT
- name: Create Pull Request
uses: peter-evans/[email protected]
with:
commit-message: ${{ steps.dump-logs.outputs.msg }}
title: ${{ steps.dump-logs.outputs.msg }}
branch: chore-docs-alice-comms
delete-branch: true
author: 'Alice OA <[email protected]>'
add-paths: docs
- name: Post engineering log entry
env:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
2 changes: 0 additions & 2 deletions scripts/discussion_dump_to_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@
import tempfile
from typing import Callable, Type, Union, NewType, Dict

import dffml

sys.path.append(str(pathlib.Path(__file__).parent.resolve()))

from dump_discussion import Reply, Comment, Discussion
Expand Down
6 changes: 6 additions & 0 deletions scripts/dump_discussion.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ async def fetch_discussion_data(session, token, owner, repo, discussion_number):
response = await session.post("https://api.github.com/graphql", headers=headers, json={"query": query, "variables": variables})
result = await response.json()

if "data" not in result:
raise Exception(json.dumps(result, indent=4, sort_keys=True))

discussion_title = result["data"]["repository"]["discussion"]["title"]
discussion_body = result["data"]["repository"]["discussion"]["body"]
comments = result["data"]["repository"]["discussion"]["comments"]["nodes"]
Expand All @@ -97,6 +100,9 @@ async def fetch_discussion_data(session, token, owner, repo, discussion_number):
response = await session.post("https://api.github.com/graphql", headers=headers, json={"query": query, "variables": variables})
reply_result = await response.json()

if "replies" not in reply_result:
raise Exception(json.dumps(reply_result, indent=4, sort_keys=True))

reply_nodes = comment["replies"]["nodes"]
has_next_reply_page = comment["replies"]["pageInfo"]["hasNextPage"]
replies_cursor = comment["replies"]["pageInfo"]["endCursor"]
Expand Down

0 comments on commit 6e5462b

Please sign in to comment.