Skip to content

Commit

Permalink
ci: Add user check to pr action (#12)
Browse files Browse the repository at this point in the history
* ci(automated commit): Build bundled file

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
thelukewalton and github-actions committed Jul 10, 2024
1 parent c58b96a commit a3bae86
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @thelukewalton
25 changes: 24 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,30 @@ on:
name: Pull Request

jobs:
pull_request:
set-env:
name: "Set environment"
runs-on: ubuntu-latest
outputs:
env: ${{ steps.get_env.outputs.env }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{github.event.pull_request.head.repo.full_name}}
ref: ${{ github.head_ref }}
- name: Determine Environment
id: get_env
run: |
codeowners=$(cat .github/CODEOWNERS)
if [[ $(echo "${codeowners[@]}" | fgrep -w "@${{github.actor}}") ]]; then
echo PROWNER
echo "env=pr_owner" >> $GITHUB_OUTPUT
else
echo PR
echo "env=pr" >> $GITHUB_OUTPUT
fi
pull_request_checks:
needs: set-env
environment: ${{needs.set-env.outputs.env}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30430,6 +30430,7 @@ const exec_1 = __nccwpck_require__(2259);
const core_1 = __nccwpck_require__(2614);
exports.ANALYZE_SUCCESS = "✅ - Static analysis passed";
exports.ANALYZE_FAILURE = "⛔️ - Static analysis failed";
const ANALYZE_PASS_LOG = "No issues found!";
const getAnalyze = async () => {
(0, core_1.startGroup)("Analyzing code");
let response;
Expand All @@ -30440,7 +30441,12 @@ const getAnalyze = async () => {
stdout: (data) => (stdout += data.toString()),
},
});
response = { output: exports.ANALYZE_SUCCESS, error: false };
if (stdout.includes(ANALYZE_PASS_LOG)) {
response = { output: exports.ANALYZE_SUCCESS, error: false };
}
else {
throw new Error("Issues found");
}
}
catch (error) {
const arr = stdout.trim().split("\n");
Expand Down

0 comments on commit a3bae86

Please sign in to comment.