From a3bae864f0399d27a4108afc1da117d7f0c751b4 Mon Sep 17 00:00:00 2001 From: Luke Walton Date: Wed, 10 Jul 2024 13:28:24 +0100 Subject: [PATCH] ci: Add user check to pr action (#12) * ci(automated commit): Build bundled file --------- Co-authored-by: github-actions --- .github/CODEOWNERS | 1 + .github/workflows/pull-request.yml | 25 ++++++++++++++++++++++++- dist/index.js | 8 +++++++- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..541f77c --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @thelukewalton \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 305571f..1260d4e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -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 diff --git a/dist/index.js b/dist/index.js index 90d0b50..a09c544 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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; @@ -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");