Skip to content
Open

t1 #1

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
30 changes: 26 additions & 4 deletions .github/workflows/push_to_prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:
with:
ref: "main"
fetch-depth: 0
- name: List .github directory
run: |
ls -la
ls -la .github
- name: Ensure PR was approved by Code Owner
id: check_approval
uses: actions/github-script@v7
Expand All @@ -28,13 +32,31 @@ jobs:
repo: context.repo.repo,
pull_number: prNumber
});
//const codeOwners = ['cdc-as81', 'gilsharon321']; // Replace with actual code owners
const fs = require('fs');
const path = require('path');
//const codeownersPath = path.join(process.env.GITHUB_WORKSPACE, '.github', 'CODEOWNERS');
const codeownersPath = path.join('.github', 'CODEOWNERS');
let codeOwners = [];
try {
const codeownersContent = fs.readFileSync(codeownersPath, 'utf8');
codeOwners = codeownersContent
.split('\n')
.map(line => line.trim())
.filter(line => line && !line.startsWith('#'))
.flatMap(line => line.split(/\s+/).slice(1)) // skip the pattern, get owners
.map(owner => owner.startsWith('@') ? owner.slice(1) : owner)
.filter((owner, idx, arr) => arr.indexOf(owner) === idx); // unique
} catch (err) {
core.setFailed(`Failed to read CODEOWNERS: ${err.message}`);
}
const reviewsFromCodeOwners = reviews.filter(r =>
r.state === 'APPROVED' && codeOwners.includes(r.user.login));

const approvals = reviews.filter(r => r.state === 'APPROVED');

if (approvals.length === 0) {
if (reviewsFromCodeOwners.length === 0) {
core.setFailed('No approvals from code owners.');
} else {
console.log(`Found ${approvals.length} approval(s)`);
console.log(`Found ${reviewsFromCodeOwners.length} approvals from code owners`);
}
- name: Pull from main and push to production
if: success()
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# sandbox
# sandbox

123