Skip to content

Commit

Permalink
Merge pull request #31 from pedrox-hs/improvement/gh-checks
Browse files Browse the repository at this point in the history
Update GitHub checks workflows
  • Loading branch information
kodiakhq[bot] authored Jan 1, 2024
2 parents 88247b8 + 84c7bd2 commit e43d902
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/autoapproval.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from_owner:
- pedrox-hs
required_labels:
- autoapprove
- autoapproval
apply_labels:
- automerge
ignored_labels:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/alls-green.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: Alls green

on:
push:
branches:
- main
pull_request:
types: [opened, reopened, synchronize, ready_for_review, labeled]

concurrency:
group: alls-green-${{ github.sha }}
group: alls-green-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand Down
78 changes: 2 additions & 76 deletions .github/workflows/autoapproval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,84 +7,10 @@ on:
types:
- completed

concurrency:
group: autoapproval-${{ github.ref }}
cancel-in-progress: true

jobs:
approval-list:
name: Generate approval list
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
outputs:
matrix: ${{ steps.prs.outputs.result }}

steps:
- name: Get Pull Request data
id: prs
uses: actions/github-script@v7
with:
script: |
const pullRequests = context.payload.workflow_run.pull_requests;
const { name: repoName, owner: { login: ownerName } } = context.payload.workflow_run.repository;
let approvals = [];
for (const pr of pullRequests) {
// get pull request data
const { data: pullRequest } = await github.rest.pulls.get({
owner: ownerName,
repo: repoName,
pull_number: pr.number,
});
// if PR is not open or is a draft, skip
if (pullRequest.draft || pullRequest.state !== 'open') {
github.log.debug(`Skipping PR #${pullRequest.number} with state ${pullRequest.state}.`);
continue;
}
// get collaborator permission level
const { data: { permission } } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: ownerName,
repo: repoName,
username: pullRequest.user.login,
});
// only add PRs that have write or admin permissions
github.log.debug(`The collaborator ${pullRequest.user.login} has permission ${permission}.`);
if (permission == 'admin' || permission == 'write') {
approvals.push({
owner: ownerName,
repo: repoName,
number: pullRequest.number,
});
}
}
github.log.debug(`Approvals: ${JSON.stringify(approvals, null, 2)}`);
return {
include: approvals,
};
autoapproval:
name: Autoapproval
runs-on: ubuntu-latest
needs: approval-list
if: ${{ needs.approval-list.outputs.matrix && needs.approval-list.outputs.matrix != '{"include":[]}' }}
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.pull_requests }}
permissions:
contents: read
pull-requests: write

strategy:
fail-fast: false
matrix: ${{ fromJson(needs.approval-list.outputs.matrix )}}

steps:
- name: Autoapproval
uses: pedrox-hs/autoapproval@main
with:
repository: "${{ matrix.owner }}/${{ matrix.repo }}"
pr_number: ${{ matrix.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: pedrox-hs/autoapproval/.github/workflows/try-autoapproval.yml@main

0 comments on commit e43d902

Please sign in to comment.