Skip to content

feat: WIP add template gha for code reviews [] #3

feat: WIP add template gha for code reviews []

feat: WIP add template gha for code reviews [] #3

name: 'App Review Check'
on:
pull_request:
# types:
# - opened
# - edited
# - synchronize
# branches:
# - 'main'
# - 'feat/gha-code-review'
permissions:
pull-requests: write
jobs:
main:
name: App Review Check
runs-on: ubuntu-latest
steps:
- run: echo "Checking for app review"
- name: Check if new app submission
id: check_new_app_submission
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
const newAppDirs = files
.filter(file => file.status === 'added' && file.filename.startsWith('marketplace-partner-apps/apps/'))
.map(file => file.filename.split('/').slice(0, 3).join('/'));
const uniqueNewAppDirs = [...new Set(newAppDirs)];
if (uniqueNewAppDirs.length === 0) {
console.log('No new app submissions found.');
return;
}
console.log('New app submissions found:', uniqueNewAppDirs);
core.setOutput('new_app_dirs', uniqueNewAppDirs.join(','));
# - name: Check for LICENSE file in new apps
# if: steps.check_new_app.outputs.new_app_dirs
# id: check_license
# run: |
# new_app_dirs=(${{ steps.check_new_app.outputs.new_app_dirs }})
# for app_dir in "${new_app_dirs[@]}"; do
# if [ ! -f "${app_dir}/LICENSE" ]; then
# echo "LICENSE file is missing in the new app directory ${app_dir}."
# exit 1
# fi
# done
# echo "LICENSE file exists in all new app directories."
# - name: Check for LICENSE file in PR
# id: check_license
# run: |
# if ! git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q '^LICENSE$'; then
# echo "LICENSE file is missing in the pull request."
# exit 1
# fi
# echo "LICENSE file exists in the pull request."
- name: Add a comment and label to the PR
uses: actions/github-script@v7
with:
script: |
const issue_number = context.payload.pull_request.number;
const comment_body = 'Thank you for your pull request! We will review it shortly.';
const label_name = 'needs review';
// Add a comment to the PR
await github.rest.issues.createComment({
...context.repo,
issue_number,
body: comment_body,
});
// Add a label to the PR
await github.rest.issues.addLabels({
...context.repo,
issue_number,
labels: [label_name],
});