Skip to content
Open
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
76 changes: 76 additions & 0 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

name: CsI only after 2 approvals

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, review_requested]
pull_request_review:
types: [submitted]

permissions:
contents: read
pull-requests: read

jobs:
check-approvals:
runs-on: ubuntu-latest
outputs:
approved: ${{ steps.check.outputs.approved }}
count: ${{ steps.check.outputs.count }}
steps:
- name: Print event basics
run: |
echo "Event name : ${{ github.event_name }}"
echo "Event action : ${{ github.event.action }}"
echo "Review state : ${{ github.event.review.state || 'n/a' }}"
echo "PR number : ${{ github.event.pull_request.number }}"

- name: Count unique latest approvals
id: check
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const prNumber = context.payload.pull_request.number;

// Fetch all reviews for the PR
const { data: reviews } = await github.rest.pulls.listReviews({
owner, repo, pull_number: prNumber, per_page: 100
});

// Keep only the latest review per user
const latestByUser = new Map();
for (const r of reviews) {
const key = r.user?.login;
const prev = latestByUser.get(key);
if (!prev || new Date(r.submitted_at) > new Date(prev.submitted_at)) {
latestByUser.set(key, r);
}
}

// Count users whose latest state is APPROVED
const approvers = [...latestByUser.values()]
.filter(r => r.state === 'APPROVED')
.map(r => r.user.login);

const count = approvers.length;
const threshold = 2;

core.info(`Approvals (${count}): ${approvers.join(', ')}`);
core.setOutput('count', String(count));
core.setOutput('approved', String(count >= threshold));

build:
needs: check-approvals
# Run only when the approval gate says "true"
if: needs.check-approvals.outputs.approved == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
echo "Approval count: ${{ needs.check-approvals.outputs.count }}"
echo "Running because at least 2 approvals are present."
# Place your real CI steps here (build/test/deploy etc.)

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# h2xml

#touch this
#this is attea
## Introduction
H2XML (Header to XML) is a generic tool for generating XML files from annotated
C header files with Grammar and syntax of the annotations are similar to
Expand Down