├── .github ├── CODEOWNERS └── workflows │ ├── comment_issue.yml │ ├── create_issue.yml │ ├── create_issue_on_label.yml │ └── publish-action.yml ├── LICENSE ├── README.md ├── action.yml └── images ├── codacy-analysis-integration.png ├── codacy-logo.svg ├── failed-workflow.png └── github-code-scanning.png /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | README.md @codacy/techwriters 2 | -------------------------------------------------------------------------------- /.github/workflows/comment_issue.yml: -------------------------------------------------------------------------------- 1 | name: Comment issue on Jira 2 | 3 | on: 4 | issue_comment: 5 | types: [created] 6 | 7 | jobs: 8 | jira: 9 | env: 10 | JIRA_CREATE_COMMENT_AUTO: ${{ secrets.JIRA_CREATE_COMMENT_AUTO }} 11 | runs-on: ubuntu-latest 12 | steps: 13 | 14 | - name: Start workflow if JIRA_CREATE_COMMENT_AUTO is enabled 15 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' 16 | run: echo "Starting workflow" 17 | 18 | - name: Check GitHub Issue type 19 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' 20 | id: github_issue_type 21 | uses: actions/github-script@v2.0.0 22 | with: 23 | result-encoding: string 24 | script: | 25 | // An Issue can be a pull request, you can identify pull requests by the pull_request key 26 | const pullRequest = ${{ toJson(github.event.issue.pull_request) }} 27 | if(pullRequest) { 28 | return "pull-request" 29 | } else { 30 | return "issue" 31 | } 32 | 33 | - name: Check if GitHub Issue has JIRA_ISSUE_LABEL 34 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' 35 | id: github_issue_has_jira_issue_label 36 | uses: actions/github-script@v2.0.0 37 | env: 38 | JIRA_ISSUE_LABEL: ${{ secrets.JIRA_ISSUE_LABEL }} 39 | with: 40 | result-encoding: string 41 | script: | 42 | const labels = ${{ toJson(github.event.issue.labels) }} 43 | if(labels.find(label => label.name == process.env.JIRA_ISSUE_LABEL)) { 44 | return "true" 45 | } else { 46 | return "false" 47 | } 48 | 49 | - name: Continue workflow only for Issues (not Pull Requests) tagged with JIRA_ISSUE_LABEL 50 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' 51 | env: 52 | GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} 53 | GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} 54 | run: echo "GitHub Issue is tracked on Jira, eligilbe to be commented" 55 | 56 | - name: Jira Login 57 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' 58 | id: login 59 | uses: atlassian/gajira-login@v2.0.0 60 | env: 61 | GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} 62 | GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} 63 | JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} 64 | JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} 65 | JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} 66 | 67 | - name: Extract Jira number 68 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' 69 | id: extract_jira_number 70 | uses: actions/github-script@v2.0.0 71 | env: 72 | GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} 73 | GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} 74 | JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }} 75 | GITHUB_TITLE: ${{ github.event.issue.title }} 76 | with: 77 | script: | 78 | const jiraTaskRegex = new RegExp(`\\\[(${process.env.JIRA_PROJECT}-[0-9]+?)\\\]`) 79 | return process.env.GITHUB_TITLE.match(jiraTaskRegex)[1] 80 | result-encoding: string 81 | 82 | - name: Jira Add comment on issue 83 | if: env.JIRA_CREATE_COMMENT_AUTO == 'true' && env.GITHUB_ISSUE_TYPE == 'issue' && env.GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL == 'true' 84 | id: add_comment_jira_issue 85 | uses: atlassian/gajira-comment@v2.0.2 86 | env: 87 | GITHUB_ISSUE_TYPE: ${{ steps.github_issue_type.outputs.result }} 88 | GITHUB_ISSUE_HAS_JIRA_ISSUE_LABEL: ${{ steps.github_issue_has_jira_issue_label.outputs.result }} 89 | with: 90 | issue: ${{ steps.extract_jira_number.outputs.result }} 91 | comment: | 92 | GitHub Comment : ${{ github.event.comment.user.login }} 93 | {quote}${{ github.event.comment.body }}{quote} 94 | ---- 95 | {panel} 96 | _[Github permalink |${{ github.event.comment.html_url }}]_ 97 | {panel} 98 | -------------------------------------------------------------------------------- /.github/workflows/create_issue.yml: -------------------------------------------------------------------------------- 1 | name: Create issue on Jira 2 | 3 | on: 4 | issues: 5 | types: [opened] 6 | 7 | jobs: 8 | jira: 9 | env: 10 | JIRA_CREATE_ISSUE_AUTO: ${{ secrets.JIRA_CREATE_ISSUE_AUTO }} 11 | runs-on: ubuntu-latest 12 | steps: 13 | 14 | - name: Start workflow if JIRA_CREATE_ISSUE_AUTO is enabled 15 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' 16 | run: echo "Starting workflow" 17 | 18 | - name: Jira Login 19 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' 20 | id: login 21 | uses: atlassian/gajira-login@v2.0.0 22 | env: 23 | JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} 24 | JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} 25 | JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} 26 | 27 | - name: Jira Create issue 28 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' 29 | id: create_jira_issue 30 | uses: atlassian/gajira-create@v2.0.1 31 | with: 32 | project: ${{ secrets.JIRA_PROJECT }} 33 | issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} 34 | summary: "[GH#${{ github.event.issue.number }}] ${{ github.event.issue.title }}" 35 | description: | 36 | ${{ github.event.issue.body }} 37 | ---- 38 | {panel} 39 | _[Github permalink |${{ github.event.issue.html_url }}]_ 40 | {panel} 41 | 42 | - name: Update Jira issue if JIRA_UPDATE_ISSUE_BODY is defined 43 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' && env.JIRA_UPDATE_ISSUE_BODY != '' 44 | env: 45 | JIRA_UPDATE_ISSUE_BODY: ${{ secrets.JIRA_UPDATE_ISSUE_BODY }} 46 | run: > 47 | curl 48 | -u ${{ secrets.JIRA_USER_EMAIL }}:${{ secrets.JIRA_API_TOKEN }} 49 | -X PUT 50 | -H 'Content-Type: application/json' 51 | -d '${{ env.JIRA_UPDATE_ISSUE_BODY }}' 52 | ${{ secrets.JIRA_BASE_URL }}/rest/api/2/issue/${{ steps.create_jira_issue.outputs.issue }} 53 | 54 | - name: Update GitHub issue 55 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' 56 | uses: actions/github-script@v2.0.0 57 | env: 58 | JIRA_ISSUE_NUMBER: ${{ steps.create_jira_issue.outputs.issue }} 59 | GITHUB_ORIGINAL_TITLE: ${{ github.event.issue.title }} 60 | JIRA_ISSUE_LABEL: ${{ secrets.JIRA_ISSUE_LABEL }} 61 | with: 62 | github-token: ${{secrets.GITHUB_TOKEN}} 63 | script: | 64 | const newTitle = `[${process.env.JIRA_ISSUE_NUMBER}] ${process.env.GITHUB_ORIGINAL_TITLE}` 65 | github.issues.update({ 66 | issue_number: context.issue.number, 67 | owner: context.repo.owner, 68 | repo: context.repo.repo, 69 | title: newTitle 70 | }) 71 | github.issues.addLabels({ 72 | issue_number: context.issue.number, 73 | owner: context.repo.owner, 74 | repo: context.repo.repo, 75 | labels: [process.env.JIRA_ISSUE_LABEL] 76 | }) 77 | 78 | 79 | - name: Add comment after sync 80 | if: env.JIRA_CREATE_ISSUE_AUTO == 'true' 81 | uses: actions/github-script@v2.0.0 82 | with: 83 | github-token: ${{secrets.GITHUB_TOKEN}} 84 | script: | 85 | github.issues.createComment({ 86 | issue_number: context.issue.number, 87 | owner: context.repo.owner, 88 | repo: context.repo.repo, 89 | body: 'Internal ticket created : [${{ steps.create_jira_issue.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create_jira_issue.outputs.issue }})' 90 | }) 91 | -------------------------------------------------------------------------------- /.github/workflows/create_issue_on_label.yml: -------------------------------------------------------------------------------- 1 | name: Create issue on Jira when labeled with JIRA_ISSUE_LABEL 2 | 3 | on: 4 | issues: 5 | types: [labeled] 6 | 7 | jobs: 8 | jira: 9 | env: 10 | JIRA_ISSUE_LABEL: ${{ secrets.JIRA_ISSUE_LABEL }} 11 | runs-on: ubuntu-latest 12 | steps: 13 | 14 | - name: Start workflow if GitHub issue is tagged with JIRA_ISSUE_LABEL 15 | if: github.event.label.name == env.JIRA_ISSUE_LABEL 16 | run: echo "Starting workflow" 17 | 18 | - name: Jira Login 19 | if: github.event.label.name == env.JIRA_ISSUE_LABEL 20 | id: login 21 | uses: atlassian/gajira-login@v2.0.0 22 | env: 23 | JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} 24 | JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} 25 | JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} 26 | 27 | - name: Jira Create issue 28 | if: github.event.label.name == env.JIRA_ISSUE_LABEL 29 | id: create_jira_issue 30 | uses: atlassian/gajira-create@v2.0.1 31 | with: 32 | project: ${{ secrets.JIRA_PROJECT }} 33 | issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} 34 | summary: "[GH#${{ github.event.issue.number }}] ${{ github.event.issue.title }}" 35 | description: | 36 | ${{ github.event.issue.body }} 37 | ---- 38 | {panel} 39 | _[Github permalink |${{ github.event.issue.html_url }}]_ 40 | {panel} 41 | 42 | - name: Update Jira issue if JIRA_UPDATE_ISSUE_BODY is defined 43 | if: github.event.label.name == env.JIRA_ISSUE_LABEL && env.JIRA_UPDATE_ISSUE_BODY != '' 44 | env: 45 | JIRA_UPDATE_ISSUE_BODY: ${{ secrets.JIRA_UPDATE_ISSUE_BODY }} 46 | run: > 47 | curl 48 | -u ${{ secrets.JIRA_USER_EMAIL }}:${{ secrets.JIRA_API_TOKEN }} 49 | -X PUT 50 | -H 'Content-Type: application/json' 51 | -d '${{ env.JIRA_UPDATE_ISSUE_BODY }}' 52 | ${{ secrets.JIRA_BASE_URL }}/rest/api/2/issue/${{ steps.create_jira_issue.outputs.issue }} 53 | 54 | - name: Change Title 55 | if: github.event.label.name == env.JIRA_ISSUE_LABEL 56 | uses: actions/github-script@v2.0.0 57 | env: 58 | JIRA_ISSUE_NUMBER: ${{ steps.create_jira_issue.outputs.issue }} 59 | GITHUB_ORIGINAL_TITLE: ${{ github.event.issue.title }} 60 | with: 61 | github-token: ${{secrets.GITHUB_TOKEN}} 62 | script: | 63 | const newTitle = `[${process.env.JIRA_ISSUE_NUMBER}] ${process.env.GITHUB_ORIGINAL_TITLE}` 64 | github.issues.update({ 65 | issue_number: context.issue.number, 66 | owner: context.repo.owner, 67 | repo: context.repo.repo, 68 | title: newTitle 69 | }) 70 | 71 | - name: Add comment after sync 72 | if: github.event.label.name == env.JIRA_ISSUE_LABEL 73 | uses: actions/github-script@v2.0.0 74 | with: 75 | github-token: ${{secrets.GITHUB_TOKEN}} 76 | script: | 77 | github.issues.createComment({ 78 | issue_number: context.issue.number, 79 | owner: context.repo.owner, 80 | repo: context.repo.repo, 81 | body: 'Internal ticket created : [${{ steps.create_jira_issue.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create_jira_issue.outputs.issue }})' 82 | }) 83 | -------------------------------------------------------------------------------- /.github/workflows/publish-action.yml: -------------------------------------------------------------------------------- 1 | name: publish-action 2 | 3 | on: 4 | push: 5 | tags: 6 | - "*" 7 | 8 | jobs: 9 | release: 10 | name: Release GitHub Actions 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Release GitHub Actions 14 | uses: technote-space/release-github-actions@v4 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Codacy Analysis CLI GitHub Action 2 | 3 | [![Codacy Badge](https://app.codacy.com/project/badge/Grade/946b78614f154f81b1c9c0514fd9f35c)](https://www.codacy.com/gh/codacy/codacy-analysis-cli-action/dashboard?utm_source=github.com&utm_medium=referral&utm_content=codacy/codacy-analysis-cli-action&utm_campaign=Badge_Grade) 4 | 5 | GitHub Action for running Codacy static analysis on [over 40 supported languages](https://docs.codacy.com/getting-started/supported-languages-and-tools/) and returning identified issues in the code. 6 | 7 |
8 | 9 | Codacy 10 | 11 |
12 | 13 | [Codacy](https://www.codacy.com/) is an automated code review tool that makes it easy to ensure your team is writing high-quality code by analyzing more than 40 programming languages such as PHP, JavaScript, Python, Java, and Ruby. Codacy allows you to define your own quality rules, code patterns and quality settings you'd like to enforce to prevent issues on your codebase. 14 | 15 | The Codacy GitHub Action supports the following scenarios: 16 | 17 | - **[Analysis with default settings](#analysis-with-default-settings):** Analyzes each commit and pull request and fails the workflow if it finds issues in your code. 18 | - **[Integration with GitHub code scanning](#integration-with-github-code-scanning):** Analyzes each commit and pull request and uploads the results to GitHub, which displays the identified issues under your repository's tab **Security**. 19 | - **[Integration with Codacy for client-side tools](#integration-with-codacy-for-client-side-tools):** Analyzes each commit and pull request using one of Codacy's client-side tools and uploads the results to Codacy, which displays the identified issues in UI dashboards and can also report the status of the analysis on your pull requests. 20 | 21 | ## Analysis with default settings 22 | 23 | By default, the Codacy GitHub Action: 24 | 25 | - Analyzes each commit or pull request by running all supported static code analysis tools for the languages found in your repository. 26 | - Prints the analysis results on the console, which is visible on the GitHub Action's workflow panel. 27 | - Fails the workflow if it finds at least one issue in your code. 28 | 29 | ![Failed Codacy analysis workflow](images/failed-workflow.png) 30 | 31 | To use the GitHub Action with default settings, add the following to a file `.github/workflows/codacy-analysis.yaml` in your repository: 32 | 33 | ```yaml 34 | name: Codacy Analysis CLI 35 | 36 | on: ["push"] 37 | 38 | jobs: 39 | codacy-analysis-cli: 40 | name: Codacy Analysis CLI 41 | runs-on: ubuntu-latest 42 | steps: 43 | - name: Checkout code 44 | uses: actions/checkout@main 45 | 46 | - name: Run Codacy Analysis CLI 47 | uses: codacy/codacy-analysis-cli-action@master 48 | ``` 49 | 50 | ## Integration with GitHub code scanning 51 | 52 | Integrate the Codacy GitHub Action with [GitHub code scanning](https://docs.github.com/github/finding-security-vulnerabilities-and-errors-in-your-code/about-code-scanning) to display the analysis results on your repository under the tab **Security**, page **Code scanning alerts**. 53 | 54 | In this scenario, the GitHub Action: 55 | 56 | - Analyzes each commit and pull request to the `master` or `main` branch by running all supported static code analysis tools for the languages found in your repository. 57 | - Outputs the analysis results to a file `results.sarif`, which is then uploaded to GitHub. 58 | 59 | ![GitHub code scanning integration](images/github-code-scanning.png) 60 | 61 | To use the GitHub Action with GitHub code scanning integration, add the following to a file `.github/workflows/codacy-analysis.yaml` in your repository: 62 | 63 | ```yaml 64 | name: Codacy Security Scan 65 | 66 | on: 67 | push: 68 | branches: [ "master", "main" ] 69 | pull_request: 70 | branches: [ "master", "main" ] 71 | 72 | jobs: 73 | codacy-security-scan: 74 | name: Codacy Security Scan 75 | runs-on: ubuntu-latest 76 | steps: 77 | - name: Checkout code 78 | uses: actions/checkout@main 79 | 80 | - name: Run Codacy Analysis CLI 81 | uses: codacy/codacy-analysis-cli-action@master 82 | with: 83 | output: results.sarif 84 | format: sarif 85 | # Adjust severity of non-security issues 86 | gh-code-scanning-compat: true 87 | # Force 0 exit code to allow SARIF file generation 88 | # This will hand over control about PR rejection to the GitHub side 89 | max-allowed-issues: 2147483647 90 | 91 | # Upload the SARIF file generated in the previous step 92 | - name: Upload SARIF results file 93 | uses: github/codeql-action/upload-sarif@main 94 | with: 95 | sarif_file: results.sarif 96 | ``` 97 | 98 | ## Integration with Codacy for client-side tools 99 | 100 | Use the GitHub Action to run any of the [**containerized** client-side tools supported by Codacy](https://docs.codacy.com/related-tools/local-analysis/client-side-tools/) and upload the results of the analysis to Codacy. 101 | 102 | In this scenario, the GitHub action: 103 | 104 | - Analyzes each commit or pull request by running a specific client-side tool with the configurations that you defined on Codacy. 105 | - Uploads the analysis results to Codacy. 106 | 107 | After this, Codacy displays the results of the analysis of your commits and pull requests on the UI dashboards, and optionally reports the status of the analysis directly on your GitHub pull requests. 108 | 109 | ![Codacy integration](images/codacy-analysis-integration.png) 110 | 111 | To use the GitHub Action with Codacy integration: 112 | 113 | 1. On Codacy, [enable the containerized client-side tool](../../repositories-configure/configuring-code-patterns.md) and configure the corresponding code patterns on your repository **Code patterns** page. 114 | 115 | 1. On Codacy, enable **Run analysis through build server** in your repository **Settings**, tab **General**, **Repository analysis**. 116 | 117 | This setting enables Codacy to wait for the results of the local analysis before resuming the analysis of your commits. 118 | 119 | 2. Set up an API token to allow the GitHub Action to authenticate on Codacy: 120 | 121 | - **If you're setting up one repository**, [obtain a project API token](https://docs.codacy.com/codacy-api/api-tokens/#project-api-tokens) and store it as an [encrypted secret for your **repository**](https://docs.github.com/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) with the name `CODACY_PROJECT_TOKEN`. 122 | - **If you're setting up multiple repositories**, [obtain an account API token](https://docs.codacy.com/codacy-api/api-tokens/#account-api-tokens) and store it as an [encrypted secret for your **organization**](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-an-organization) with the name `CODACY_API_TOKEN`. 123 | 124 | > ⚠️ **Never write API tokens to your configuration files** and keep your API tokens well protected, as they grant owner permissions to your projects on Codacy. 125 | 126 | 3. Add the following to a file `.github/workflows/codacy-analysis.yaml` in your repository, where `` is the name of the [containerized client-side tool](https://docs.codacy.com/related-tools/local-analysis/client-side-tools/) that the Codacy Analysis CLI will run locally, or don't specify this parameter to run all tools supported by Codacy: 127 | 128 | ```yaml 129 | name: Codacy Analysis CLI 130 | 131 | on: ["push"] 132 | 133 | jobs: 134 | codacy-analysis-cli: 135 | name: Codacy Analysis CLI 136 | runs-on: ubuntu-latest 137 | steps: 138 | - name: Checkout code 139 | uses: actions/checkout@main 140 | 141 | - name: Run Codacy Analysis CLI 142 | uses: codacy/codacy-analysis-cli-action@master 143 | with: 144 | tool: 145 | project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} 146 | # or 147 | # api-token: ${{ secrets.CODACY_API_TOKEN }} 148 | upload: true 149 | max-allowed-issues: 2147483647 150 | ``` 151 | 152 | **If you're running a Go client-side tool** you must also set up the Go environment before running the Codacy Analysis CLI GitHub Action. We recommend using the [setup-go GitHub Action](https://github.com/actions/setup-go) for this: 153 | 154 | ```yaml 155 | - name: set-up go 156 | uses: actions/setup-go@v3 157 | with: 158 | # Go version currently supported by Codacy 159 | go-version: 1.19.1 160 | ``` 161 | 162 | 4. Optionally, specify the following parameters to run [**standalone** client-side tools](https://docs.codacy.com/related-tools/local-analysis/client-side-tools/): 163 | 164 | ```yaml 165 | run-gosec: "true" 166 | run-staticcheck: "true" 167 | ``` 168 | 169 | Due to the complex orchestration of the tools Clang-Tidy and Faux Pas, the action can receive instead the output files of the tools and upload them to Codacy: 170 | 171 | ```yaml 172 | clang-tidy-output: "path/to/output" 173 | faux-pas-output: "path/to/output" 174 | ``` 175 | 176 | If you only want to run the standalone client-side tools and not all the containerized tools supported by Codacy, specify: 177 | 178 | ```yaml 179 | run-docker-tools: "false" 180 | ``` 181 | 182 | 5. Optionally, [enable the GitHub integration](https://docs.codacy.com/repositories-configure/integrations/github-integration/) on Codacy to have information about the analysis of the changed files directly on your pull requests. 183 | 184 | ## Parameters 185 | 186 | The Codacy GitHub Action is a wrapper for running the [Codacy Analysis CLI](https://github.com/codacy/codacy-analysis-cli). For a list of supported input parameters, see [`action.yml`](./action.yml). To pass input parameters to the action, [update the associated `with` map](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsstepswith). 187 | 188 | The following example limits analysis to a `src` directory and provides additional details by setting `verbose` to `true`. 189 | 190 | ```yaml 191 | - name: Run Codacy Analysis CLI 192 | uses: codacy/codacy-analysis-cli-action@master 193 | with: 194 | directory: src 195 | verbose: true 196 | ``` 197 | 198 | ## Contributing 199 | 200 | We love contributions, feedback, and bug reports. 201 | If you run into issues while running this action, 202 | [open an issue](https://github.com/codacy/codacy-analysis-cli-action/issues) in this repository. 203 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | # action.yml 2 | name: "Codacy Analysis CLI" 3 | author: "Codacy" 4 | description: "Execute Codacy code analysis using your remote Codacy configuration" 5 | branding: 6 | icon: "check" 7 | color: "gray-dark" 8 | inputs: 9 | verbose: 10 | required: false 11 | description: "Run with verbose output" 12 | project-token: 13 | required: false 14 | description: "API project token to retrieve your remote Codacy configuration for the project being analyzed" 15 | api-token: 16 | required: false 17 | description: "API account token to retrieve your remote Codacy configuration for the project being analyzed" 18 | codacy-api-base-url: 19 | required: false 20 | description: "Codacy API URL to retrieve your remote Codacy configuration" 21 | format: 22 | required: false 23 | description: "Output file format" 24 | output: 25 | required: false 26 | description: "Path to a file to save the analysis results" 27 | directory: 28 | required: false 29 | description: "Directory to analyze" 30 | parallel: 31 | required: false 32 | description: "Number of tools to run in parallel" 33 | max-tool-memory: 34 | required: false 35 | description: "Maximum allowed memory for running each tool (bytes)" 36 | max-allowed-issues: 37 | required: false 38 | default: "2147483647" 39 | description: "Maximum number of issues allowed for the analysis to succeed" 40 | registry-address: 41 | required: false 42 | default: "" 43 | description: "Alternative registry address (e.g. artprod.mycompany/)" 44 | tool: 45 | required: false 46 | description: >- 47 | Only run a specific tool or tool category (metrics, issues, duplication). 48 | For the full list of tools, see https://docs.codacy.com/repositories-configure/codacy-configuration-file/#which-tools-can-be-configured-and-which-name-should-i-use 49 | tool-timeout: 50 | required: false 51 | description: "Tool execution timeout (e.g. 15minutes, 1hour)" 52 | upload: 53 | required: false 54 | description: "Upload analysis results to Codacy" 55 | upload-batch-size: 56 | required: false 57 | description: "Maximum number of results in each batch to upload to Codacy" 58 | fail-if-incomplete: 59 | required: false 60 | description: "Fail the analysis if any tool fails to run" 61 | allow-network: 62 | required: false 63 | description: "Allow the tools to access the network" 64 | force-file-permissions: 65 | required: false 66 | description: "Force files to be readable by changing the permissions before running the analysis" 67 | gh-code-scanning-compat: 68 | required: false 69 | description: >- 70 | Reduce issue severity by one level for non-security issues, for compatibility with GitHub's code scanning feature. 71 | This option only has an effect when used with 'format: sarif'. 72 | run-docker-tools: 73 | required: false 74 | default: "true" 75 | description: >- 76 | Run all dockerized tools supported by Codacy. 77 | For the full list of tools, see https://docs.codacy.com/repositories-configure/codacy-configuration-file/#which-tools-can-be-configured-and-which-name-should-i-use 78 | run-gosec: 79 | required: false 80 | description: "Run Gosec" 81 | run-staticcheck: 82 | required: false 83 | description: "Run Staticcheck" 84 | clang-tidy-output: 85 | required: false 86 | description: "Path to a file containing the output of Clang-Tidy." 87 | faux-pas-output: 88 | required: false 89 | description: "Path to a file containing the output of Faux Pas." 90 | skip-uncommitted-files-check: 91 | required: false 92 | description: "Skip validation of uncommitted changes" 93 | skip-container-engine-check: 94 | required: false 95 | description: "Skip check for the presence of a known container engine before executing" 96 | runs: 97 | using: "composite" 98 | steps: 99 | - name: "Set Global Variables" 100 | shell: bash 101 | run: | 102 | echo "CODACY_BASE_URL_OR_DEFAULT=$(if [ -n "${{ inputs.codacy-api-base-url }}" ]; then echo "${{ inputs.codacy-api-base-url }}"; else echo "https://api.codacy.com"; fi)" >> "$GITHUB_ENV" 103 | echo "OWNER_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d '/' -f 1)" >> "$GITHUB_ENV" 104 | echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d '/' -f 2)" >> "$GITHUB_ENV" 105 | echo "ORGANIZATION_PROVIDER=$(if [ "$GITHUB_SERVER_URL" == "https://github.com" ]; then echo "gh"; else echo "ghe"; fi)" >> "$GITHUB_ENV" 106 | echo "COMMIT_SHA=$(if [ "${{ github.event_name }}" == "pull_request" ]; then echo "${{ github.event.pull_request.head.sha }}"; else echo "${{ github.sha }}"; fi)" >> "$GITHUB_ENV" 107 | if [ -n "${{ inputs.skip-container-engine-check }}" ]; then 108 | echo "SKIP_CONTAINER_ENGINE_CHECK=${{ inputs.skip-container-engine-check }}" >> "$GITHUB_ENV" 109 | fi 110 | 111 | - name: "Prepare curl authentication header" 112 | shell: bash 113 | run: | 114 | if [ -n "${{ inputs.api-token }}" ]; then 115 | echo "CURL_CODACY_AUTH_AUTHENTICATION=api-token: ${{ inputs.api-token }}" >> $GITHUB_ENV 116 | elif [ -n "${{ inputs.project-token }}" ]; then 117 | echo "CURL_CODACY_AUTH_AUTHENTICATION=project-token: ${{ inputs.project-token }}" >> $GITHUB_ENV 118 | elif [ "${{ inputs.upload }}" == "true" ]; then 119 | echo "At least one authentication method is required to upload results." 120 | exit 1 121 | fi 122 | 123 | - name: "Run GoSec" 124 | shell: bash 125 | run: | 126 | set -eux 127 | 128 | if [ "${{ inputs.run-gosec }}" == "true" ]; then 129 | cd /tmp 130 | curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s v2.15.0 131 | chmod +x ./bin/gosec 132 | CODACY_GOSEC_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-gosec/latest" -o-) 133 | curl -fsSL "https://artifacts.codacy.com/bin/codacy-gosec/$CODACY_GOSEC_VERSION/codacy-gosec-$CODACY_GOSEC_VERSION" -o /tmp/codacy-gosec 134 | chmod +x /tmp/codacy-gosec 135 | cd - 136 | 137 | /tmp/bin/gosec -no-fail -fmt json -log /tmp/log.txt ./... > /tmp/gosec-out.json 138 | /tmp/codacy-gosec < /tmp/gosec-out.json > /tmp/codacy-out.json 139 | if [ "${{ inputs.upload }}" == "true" ]; then 140 | curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \ 141 | -H "Content-type: application/json" --data-binary @/tmp/codacy-out.json \ 142 | "${CODACY_BASE_URL_OR_DEFAULT}/2.0/$ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME/commit/$COMMIT_SHA/issuesRemoteResults" 143 | else 144 | cat /tmp/codacy-out.json 145 | fi 146 | else 147 | echo "Skipping GoSec" 148 | fi 149 | - name: set-up go 150 | if: ${{ inputs.run-staticcheck == 'true' }} 151 | uses: actions/setup-go@v3 152 | with: 153 | go-version: 1.20.2 154 | - name: "Run StaticCheck" 155 | shell: bash 156 | run: | 157 | set -eux 158 | 159 | if [ "${{ inputs.run-staticcheck }}" == "true" ]; then 160 | cd /tmp 161 | go install honnef.co/go/tools/cmd/staticcheck@2023.1.6 162 | chmod +x /home/runner/go/bin/staticcheck 163 | CODACY_STATICCHECK_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-staticcheck/latest" -o-) 164 | curl -fsSL "https://artifacts.codacy.com/bin/codacy-staticcheck/$CODACY_STATICCHECK_VERSION/codacy-staticcheck-$CODACY_STATICCHECK_VERSION" -o /tmp/codacy-staticcheck 165 | chmod +x /tmp/codacy-staticcheck 166 | cd - 167 | 168 | find . -type f -name go.mod -exec bash -c 'cd $(dirname $1); cp $1 $1.codacy.bak; PKGS=$(go list ./...); /home/runner/go/bin/staticcheck -f json $PKGS; mv $1.codacy.bak $1' _ {} \; > /tmp/staticcheck-out.json 169 | /tmp/codacy-staticcheck < /tmp/staticcheck-out.json > /tmp/codacy-out.json 170 | if [ "${{ inputs.upload }}" == "true" ]; then 171 | curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \ 172 | -H "Content-type: application/json" --data-binary @/tmp/codacy-out.json \ 173 | "${CODACY_BASE_URL_OR_DEFAULT}/2.0/$ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME/commit/$COMMIT_SHA/issuesRemoteResults" 174 | else 175 | cat /tmp/codacy-out.json 176 | fi 177 | else 178 | echo "Skipping StaticCheck" 179 | fi 180 | 181 | - name: "Parse and Push Clang Tidy results" 182 | shell: bash 183 | run: | 184 | set -eux 185 | 186 | if [ -n "${{ inputs.clang-tidy-output }}" ]; then 187 | cd /tmp 188 | CODACY_CLANG_TIDY_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-clang-tidy/latest" -o-) 189 | curl -fsSL "https://artifacts.codacy.com/bin/codacy-clang-tidy/$CODACY_CLANG_TIDY_VERSION/codacy-clang-tidy-linux-$CODACY_CLANG_TIDY_VERSION" -o /tmp/codacy-clang-tidy 190 | chmod +x /tmp/codacy-clang-tidy 191 | cd - 192 | 193 | /tmp/codacy-clang-tidy < "${{ inputs.clang-tidy-output }}" > /tmp/codacy-out.json 194 | if [ "${{ inputs.upload }}" == "true" ]; then 195 | curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \ 196 | -H "Content-type: application/json" --data-binary @/tmp/codacy-out.json \ 197 | "${CODACY_BASE_URL_OR_DEFAULT}/2.0/$ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME/commit/$COMMIT_SHA/issuesRemoteResults" 198 | else 199 | cat /tmp/codacy-out.json 200 | fi 201 | else 202 | echo "Skipping Clang Tidy" 203 | fi 204 | 205 | - name: "Parse and Push Faux Pas results" 206 | shell: bash 207 | run: | 208 | set -eux 209 | 210 | if [ -n "${{ inputs.faux-pas-output }}" ]; then 211 | cd /tmp 212 | CODACY_FAUX_PAS_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-faux-pas/latest" -o-) 213 | curl -fsSL "https://artifacts.codacy.com/bin/codacy-faux-pas/$CODACY_FAUX_PAS_VERSION/codacy-faux-pas-$CODACY_FAUX_PAS_VERSION" -o /tmp/codacy-faux-pas 214 | chmod +x /tmp/codacy-faux-pas 215 | cd - 216 | 217 | /tmp/codacy-faux-pas < "${{ inputs.faux-pas-output }}" > /tmp/codacy-out.json 218 | if [ "${{ inputs.upload }}" == "true" ]; then 219 | curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \ 220 | -H "Content-type: application/json" --data-binary @/tmp/codacy-out.json \ 221 | "${CODACY_BASE_URL_OR_DEFAULT}/2.0/$ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME/commit/$COMMIT_SHA/issuesRemoteResults" 222 | else 223 | cat /tmp/codacy-out.json 224 | fi 225 | else 226 | echo "Skipping Faux Pas" 227 | fi 228 | 229 | - name: "Set Codacy CLI version" 230 | shell: bash 231 | run: echo "CODACY_ANALYSIS_CLI_VERSION=7.9.11" >> $GITHUB_ENV 232 | - name: "Set script path environment variable" 233 | shell: bash 234 | run: echo "CLI_SCRIPT_PATH=${{ github.action_path }}/codacy-analysis-cli.sh" >> $GITHUB_ENV 235 | - name: "Download Codacy CLI script" 236 | shell: bash 237 | run: wget -O - https://raw.githubusercontent.com/codacy/codacy-analysis-cli/${{ env.CODACY_ANALYSIS_CLI_VERSION }}/bin/codacy-analysis-cli.sh > ${{ env.CLI_SCRIPT_PATH }} 238 | - name: "Change Codacy CLI script permissions" 239 | shell: bash 240 | run: chmod +x "${{ env.CLI_SCRIPT_PATH }}" 241 | - name: "Run Codacy CLI" 242 | shell: bash 243 | run: | 244 | if [ -n "${{ inputs.registry-address }}" ]; then 245 | export REGISTRY_ADDRESS=${{ inputs.registry-address }} 246 | fi 247 | if [ "${{ inputs.run-docker-tools }}" == "true" ]; then 248 | ${{ env.CLI_SCRIPT_PATH }} \ 249 | analyze \ 250 | --skip-commit-uuid-validation \ 251 | --commit-uuid $COMMIT_SHA \ 252 | $(if [ "${{ inputs.verbose }}" == "true" ]; then echo "--verbose"; fi) \ 253 | $(if [ -n "${{ inputs.project-token }}" ]; then echo "--project-token ${{ inputs.project-token }}"; fi) \ 254 | $(if [ -n "${{ inputs.api-token }}" ]; then echo "--api-token ${{ inputs.api-token }} --username $OWNER_NAME --project $REPOSITORY_NAME --provider $ORGANIZATION_PROVIDER"; fi) \ 255 | $(if [ -n "${{ inputs.codacy-api-base-url }}" ]; then echo "--codacy-api-base-url ${{ inputs.codacy-api-base-url }}"; fi) \ 256 | $(if [ -n "${{ inputs.format }}" ]; then echo "--format ${{ inputs.format }}"; fi) \ 257 | $(if [ -n "${{ inputs.output }}" ]; then echo "--output ${{ inputs.output }}"; fi) \ 258 | $(if [ -n "${{ inputs.directory }}" ]; then echo "--directory ${{ inputs.directory }}"; fi) \ 259 | $(if [ -n "${{ inputs.parallel }}" ]; then echo "--parallel ${{ inputs.parallel }}"; fi) \ 260 | $(if [ -n "${{ inputs.max-tool-memory }}" ]; then echo "--max-tool-memory ${{ inputs.max-tool-memory }}"; fi) \ 261 | $(if [ -n "${{ inputs.max-allowed-issues }}" ]; then echo "--max-allowed-issues ${{ inputs.max-allowed-issues }}"; fi) \ 262 | $(if [ -n "${{ inputs.tool }}" ]; then echo "--tool ${{ inputs.tool }}"; fi) \ 263 | $(if [ -n "${{ inputs.tool-timeout }}" ]; then echo "--tool-timeout ${{ inputs.tool-timeout }}"; fi) \ 264 | $(if [ "${{ inputs.skip-uncommitted-files-check }}" == "true" ]; then echo "--skip-uncommitted-files-check"; fi) \ 265 | $(if [ "${{ inputs.upload }}" == "true" ]; then echo "--upload"; fi) \ 266 | $(if [ -n "${{ inputs.upload-batch-size }}" ]; then echo "--upload-batch-size ${{ inputs.upload-batch-size }}"; fi) \ 267 | $(if [ "${{ inputs.fail-if-incomplete }}" == "true" ]; then echo "--fail-if-incomplete"; fi) \ 268 | $(if [ "${{ inputs.allow-network }}" == "true" ]; then echo "--allow-network"; fi) \ 269 | $(if [ "${{ inputs.force-file-permissions }}" == "true" ]; then echo "--force-file-permissions"; fi) \ 270 | $(if [ "${{ inputs.gh-code-scanning-compat }}" == "true" ]; then echo "--gh-code-scanning-compat"; fi) \ 271 | $(if [ -n "${{ inputs.registry-address }}" ]; then echo "--registry-address ${{ inputs.registry-address }}"; fi) 272 | else 273 | echo "Skipping docker tools" 274 | fi 275 | 276 | - name: "Let Codacy know it can start processing the analysis results" 277 | shell: bash 278 | run: | 279 | if [ "${{ inputs.upload }}" == "true" ]; then 280 | echo "Uploading results for $ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME commit $COMMIT_SHA" 281 | curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \ 282 | -H "Content-type: application/json" \ 283 | "${CODACY_BASE_URL_OR_DEFAULT}/2.0/$ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME/commit/$COMMIT_SHA/resultsFinal" 284 | else 285 | echo "Skipping results upload" 286 | fi 287 | -------------------------------------------------------------------------------- /images/codacy-analysis-integration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codacy/codacy-analysis-cli-action/09916000460adeeedc96b9704f86deba53e2ad5d/images/codacy-analysis-integration.png -------------------------------------------------------------------------------- /images/codacy-logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/failed-workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codacy/codacy-analysis-cli-action/09916000460adeeedc96b9704f86deba53e2ad5d/images/failed-workflow.png -------------------------------------------------------------------------------- /images/github-code-scanning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codacy/codacy-analysis-cli-action/09916000460adeeedc96b9704f86deba53e2ad5d/images/github-code-scanning.png --------------------------------------------------------------------------------