From d3f38ad2f549392c43817b139e9570be84798b88 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 06:34:54 +0000 Subject: [PATCH 1/7] Add GitHub Actions automation to mirror repository events to LOGS Agent-Logs-Url: https://github.com/th30d4y/OpenLearnX/sessions/17fba2c8-4f49-4a78-9dc4-483acc8cc945 Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com> --- .../workflows/mirror-repo-events-to-logs.yml | 102 ++++++++++++++++++ README.md | 17 +++ 2 files changed, 119 insertions(+) create mode 100644 .github/workflows/mirror-repo-events-to-logs.yml diff --git a/.github/workflows/mirror-repo-events-to-logs.yml b/.github/workflows/mirror-repo-events-to-logs.yml new file mode 100644 index 0000000..bfcdd2f --- /dev/null +++ b/.github/workflows/mirror-repo-events-to-logs.yml @@ -0,0 +1,102 @@ +name: Mirror repository events to LOGS + +on: + push: + pull_request: + issues: + issue_comment: + pull_request_review: + pull_request_review_comment: + watch: + types: [started] + fork: + create: + delete: + workflow_dispatch: + +permissions: + contents: read + +jobs: + mirror-event-log: + runs-on: ubuntu-latest + steps: + - name: Ensure personal access token exists + env: + LOGS_REPO_PAT: ${{ secrets.LOGS_REPO_PAT }} + run: | + if [ -z "$LOGS_REPO_PAT" ]; then + echo "Missing required secret: LOGS_REPO_PAT" + exit 1 + fi + + - name: Checkout logs repository + uses: actions/checkout@v4 + with: + repository: th30d4y/LOGS + token: ${{ secrets.LOGS_REPO_PAT }} + path: logs-repo + + - name: Append event payload to daily log file + env: + SOURCE_REPOSITORY: ${{ github.repository }} + SOURCE_EVENT_NAME: ${{ github.event_name }} + SOURCE_EVENT_ACTION: ${{ github.event.action }} + SOURCE_ACTOR: ${{ github.actor }} + SOURCE_REF: ${{ github.ref }} + SOURCE_SHA: ${{ github.sha }} + SOURCE_RUN_ID: ${{ github.run_id }} + SOURCE_RUN_ATTEMPT: ${{ github.run_attempt }} + SOURCE_SERVER_URL: ${{ github.server_url }} + run: | + set -euo pipefail + export TZ=UTC + + DAY="$(date +%F)" + LOG_DIR="logs-repo/openlearnx-events/$DAY" + mkdir -p "$LOG_DIR" + LOG_FILE="$LOG_DIR/events.jsonl" + + jq -cn \ + --arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ + --arg repository "$SOURCE_REPOSITORY" \ + --arg event_name "$SOURCE_EVENT_NAME" \ + --arg event_action "$SOURCE_EVENT_ACTION" \ + --arg actor "$SOURCE_ACTOR" \ + --arg ref "$SOURCE_REF" \ + --arg sha "$SOURCE_SHA" \ + --arg run_id "$SOURCE_RUN_ID" \ + --arg run_attempt "$SOURCE_RUN_ATTEMPT" \ + --arg run_url "$SOURCE_SERVER_URL/$SOURCE_REPOSITORY/actions/runs/$SOURCE_RUN_ID" \ + --slurpfile payload "$GITHUB_EVENT_PATH" \ + '{ + timestamp: $timestamp, + source_repository: $repository, + event_name: $event_name, + event_action: (if $event_action == "" then null else $event_action end), + actor: $actor, + ref: (if $ref == "" then null else $ref end), + sha: (if $sha == "" then null else $sha end), + run: { + id: $run_id, + attempt: $run_attempt, + url: $run_url + }, + payload: $payload[0] + }' >> "$LOG_FILE" + + - name: Commit and push logs + run: | + set -euo pipefail + cd logs-repo + git config user.name "openlearnx-log-bot" + git config user.email "openlearnx-log-bot@users.noreply.github.com" + + if git diff --quiet; then + echo "No log changes to commit" + exit 0 + fi + + git add openlearnx-events + git commit -m "log(OpenLearnX): ${{ github.event_name }} @ ${{ github.run_id }}" + git push diff --git a/README.md b/README.md index b6320f0..bf13f48 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,23 @@ pnpm run dev --- +## 🧾 Repository Event Logging Automation + +This repository includes a GitHub Actions workflow at: + +- `.github/workflows/mirror-repo-events-to-logs.yml` + +It captures repository events (push, pull request activity, stars, forks, create/delete, and related interactions) and appends structured JSON logs to: + +- `https://github.com/th30d4y/LOGS` + +### Required setup + +Add this repository secret in **OpenLearnX**: + +- `LOGS_REPO_PAT`: a Personal Access Token with write access to `th30d4y/LOGS` (for example, `contents:write` on that repo). + +--- From ce99bac76dfaf3e0ca777a14a40fca6f54114d6c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 06:35:33 +0000 Subject: [PATCH 2/7] Refine log workflow checks after review feedback Agent-Logs-Url: https://github.com/th30d4y/OpenLearnX/sessions/17fba2c8-4f49-4a78-9dc4-483acc8cc945 Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com> --- .github/workflows/mirror-repo-events-to-logs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mirror-repo-events-to-logs.yml b/.github/workflows/mirror-repo-events-to-logs.yml index bfcdd2f..77c3162 100644 --- a/.github/workflows/mirror-repo-events-to-logs.yml +++ b/.github/workflows/mirror-repo-events-to-logs.yml @@ -26,7 +26,7 @@ jobs: LOGS_REPO_PAT: ${{ secrets.LOGS_REPO_PAT }} run: | if [ -z "$LOGS_REPO_PAT" ]; then - echo "Missing required secret: LOGS_REPO_PAT" + echo "Missing required secret: LOGS_REPO_PAT. See README.md for setup instructions." exit 1 fi @@ -92,7 +92,7 @@ jobs: git config user.name "openlearnx-log-bot" git config user.email "openlearnx-log-bot@users.noreply.github.com" - if git diff --quiet; then + if [ -z "$(git status --porcelain)" ]; then echo "No log changes to commit" exit 0 fi From 4ac73bbd2c6f957947471113304e03366048cd7d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 06:36:07 +0000 Subject: [PATCH 3/7] Use standard GitHub Actions bot identity for log commits Agent-Logs-Url: https://github.com/th30d4y/OpenLearnX/sessions/17fba2c8-4f49-4a78-9dc4-483acc8cc945 Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com> --- .github/workflows/mirror-repo-events-to-logs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mirror-repo-events-to-logs.yml b/.github/workflows/mirror-repo-events-to-logs.yml index 77c3162..3c04fcd 100644 --- a/.github/workflows/mirror-repo-events-to-logs.yml +++ b/.github/workflows/mirror-repo-events-to-logs.yml @@ -89,8 +89,8 @@ jobs: run: | set -euo pipefail cd logs-repo - git config user.name "openlearnx-log-bot" - git config user.email "openlearnx-log-bot@users.noreply.github.com" + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" if [ -z "$(git status --porcelain)" ]; then echo "No log changes to commit" From 86346a3e9ed0ab4bd473e404bcb26db3e9bce5b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 06:36:41 +0000 Subject: [PATCH 4/7] Harden event payload handling in log mirror workflow Agent-Logs-Url: https://github.com/th30d4y/OpenLearnX/sessions/17fba2c8-4f49-4a78-9dc4-483acc8cc945 Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com> --- .github/workflows/mirror-repo-events-to-logs.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/mirror-repo-events-to-logs.yml b/.github/workflows/mirror-repo-events-to-logs.yml index 3c04fcd..fb1911f 100644 --- a/.github/workflows/mirror-repo-events-to-logs.yml +++ b/.github/workflows/mirror-repo-events-to-logs.yml @@ -57,6 +57,11 @@ jobs: mkdir -p "$LOG_DIR" LOG_FILE="$LOG_DIR/events.jsonl" + if [ ! -r "$GITHUB_EVENT_PATH" ]; then + echo "GitHub event payload file is missing or unreadable: $GITHUB_EVENT_PATH" + exit 1 + fi + jq -cn \ --arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \ --arg repository "$SOURCE_REPOSITORY" \ From fdc4d67e48783e282d2eb70b4dac7d88eeaf1527 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 06:37:24 +0000 Subject: [PATCH 5/7] Clarify PAT permissions and centralize log root path in workflow Agent-Logs-Url: https://github.com/th30d4y/OpenLearnX/sessions/17fba2c8-4f49-4a78-9dc4-483acc8cc945 Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com> --- .github/workflows/mirror-repo-events-to-logs.yml | 6 ++++-- README.md | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mirror-repo-events-to-logs.yml b/.github/workflows/mirror-repo-events-to-logs.yml index fb1911f..bf3fb51 100644 --- a/.github/workflows/mirror-repo-events-to-logs.yml +++ b/.github/workflows/mirror-repo-events-to-logs.yml @@ -20,6 +20,8 @@ permissions: jobs: mirror-event-log: runs-on: ubuntu-latest + env: + LOG_ROOT_DIR: openlearnx-events steps: - name: Ensure personal access token exists env: @@ -53,7 +55,7 @@ jobs: export TZ=UTC DAY="$(date +%F)" - LOG_DIR="logs-repo/openlearnx-events/$DAY" + LOG_DIR="logs-repo/${LOG_ROOT_DIR}/$DAY" mkdir -p "$LOG_DIR" LOG_FILE="$LOG_DIR/events.jsonl" @@ -102,6 +104,6 @@ jobs: exit 0 fi - git add openlearnx-events + git add "${LOG_ROOT_DIR}" git commit -m "log(OpenLearnX): ${{ github.event_name }} @ ${{ github.run_id }}" git push diff --git a/README.md b/README.md index bf13f48..7f60a47 100644 --- a/README.md +++ b/README.md @@ -123,9 +123,10 @@ It captures repository events (push, pull request activity, stars, forks, create Add this repository secret in **OpenLearnX**: -- `LOGS_REPO_PAT`: a Personal Access Token with write access to `th30d4y/LOGS` (for example, `contents:write` on that repo). +- `LOGS_REPO_PAT`: a Personal Access Token that can write to `th30d4y/LOGS`. + - Fine-grained PAT: grant repository access to `th30d4y/LOGS` with **Contents: Read and write**. + - Classic PAT: use **repo** scope. --- - From c31b857c11503d71b44f247453d37e993b106134 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 06:38:00 +0000 Subject: [PATCH 6/7] Add stronger log write and payload error handling Agent-Logs-Url: https://github.com/th30d4y/OpenLearnX/sessions/17fba2c8-4f49-4a78-9dc4-483acc8cc945 Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com> --- .github/workflows/mirror-repo-events-to-logs.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mirror-repo-events-to-logs.yml b/.github/workflows/mirror-repo-events-to-logs.yml index bf3fb51..afd14af 100644 --- a/.github/workflows/mirror-repo-events-to-logs.yml +++ b/.github/workflows/mirror-repo-events-to-logs.yml @@ -60,7 +60,7 @@ jobs: LOG_FILE="$LOG_DIR/events.jsonl" if [ ! -r "$GITHUB_EVENT_PATH" ]; then - echo "GitHub event payload file is missing or unreadable: $GITHUB_EVENT_PATH" + echo "GitHub event payload file is missing or unreadable: $GITHUB_EVENT_PATH. Check workflow run environment details." exit 1 fi @@ -92,6 +92,11 @@ jobs: payload: $payload[0] }' >> "$LOG_FILE" + if [ ! -s "$LOG_FILE" ]; then + echo "Log write failed: $LOG_FILE was not created with content." + exit 1 + fi + - name: Commit and push logs run: | set -euo pipefail From 116965b0db7fb6a4ec82ae3e1d629c2915661914 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 06:38:38 +0000 Subject: [PATCH 7/7] Pin checkout action SHA and simplify bot noreply email Agent-Logs-Url: https://github.com/th30d4y/OpenLearnX/sessions/17fba2c8-4f49-4a78-9dc4-483acc8cc945 Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com> --- .github/workflows/mirror-repo-events-to-logs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mirror-repo-events-to-logs.yml b/.github/workflows/mirror-repo-events-to-logs.yml index afd14af..aeeef31 100644 --- a/.github/workflows/mirror-repo-events-to-logs.yml +++ b/.github/workflows/mirror-repo-events-to-logs.yml @@ -33,7 +33,7 @@ jobs: fi - name: Checkout logs repository - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 with: repository: th30d4y/LOGS token: ${{ secrets.LOGS_REPO_PAT }} @@ -102,7 +102,7 @@ jobs: set -euo pipefail cd logs-repo git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config user.email "github-actions[bot]@users.noreply.github.com" if [ -z "$(git status --porcelain)" ]; then echo "No log changes to commit"