|
| 1 | +name: is-repo-lint |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ "master" ] |
| 5 | + pull_request: |
| 6 | + branches: [ "master" ] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +# select correct state for repository |
| 10 | +env: |
| 11 | + # state: private |
| 12 | + state: public |
| 13 | + |
| 14 | +jobs: |
| 15 | + public-or-private-repo: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + repostate: ${{ steps.repo-state.outputs.repostate }} |
| 19 | + steps: |
| 20 | + |
| 21 | + - name: Repo state |
| 22 | + id: repo-state |
| 23 | + run: echo "repostate=${{env.state}}" >> $GITHUB_OUTPUT |
| 24 | + - name: Repo public? |
| 25 | + if: "${{ env.state == 'public' }}" |
| 26 | + run: echo "Workflow has repo set as public. If this is incorrect, uncomment line 11." |
| 27 | + - name: Repo private? |
| 28 | + if: "${{ env.state == 'private' }}" |
| 29 | + run: echo "Workflow has repo set as private. If this is incorrect, uncomment line 12." |
| 30 | + |
| 31 | + check-for-codeowners-file: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + |
| 35 | + - name: Checkout repo |
| 36 | + uses: actions/checkout@v3 |
| 37 | + |
| 38 | + - name: Check for CODEOWNERS |
| 39 | + id: codeowners_file |
| 40 | + uses: initialstate/file-check-action@v1 |
| 41 | + with: |
| 42 | + file: ".github/CODEOWNERS" |
| 43 | + |
| 44 | + - name: CODEOWNERS file Output Test |
| 45 | + run: echo ${{ steps.codeowners_file.outputs.file_exists }} |
| 46 | + |
| 47 | + - name: CODEOWNERS file exists with content |
| 48 | + if: steps.codeowners_file.outputs.file_exists == 'true' |
| 49 | + run: echo CODEOWNERS file exists! |
| 50 | + |
| 51 | + - name: CODEOWNERS file does not exist |
| 52 | + if: steps.codeowners_file.outputs.file_exists == 'false' |
| 53 | + run: echo CODEOWNERS file does not exist! |
| 54 | + |
| 55 | + check-for-readme-file: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + |
| 59 | + - name: Checkout repo |
| 60 | + uses: actions/checkout@v3 |
| 61 | + |
| 62 | + - name: Check for README.md |
| 63 | + id: readme_file |
| 64 | + uses: initialstate/file-check-action@v1 |
| 65 | + with: |
| 66 | + file: "README" |
| 67 | + |
| 68 | + - name: README file Output Test |
| 69 | + run: echo ${{ steps.readme_file.outputs.file_exists }} |
| 70 | + |
| 71 | + - name: README file exists with content |
| 72 | + if: steps.readme_file.outputs.file_exists == 'true' |
| 73 | + run: echo README file exists! |
| 74 | + |
| 75 | + - name: README file does not exist |
| 76 | + if: steps.readme_file.outputs.file_exists == 'false' |
| 77 | + run: echo README file does not exist! |
| 78 | + |
| 79 | + check-for-license: |
| 80 | + needs: public-or-private-repo |
| 81 | + if: needs.public-or-private-repo.outputs.repostate == 'public' |
| 82 | + runs-on: ubuntu-latest |
| 83 | + steps: |
| 84 | + |
| 85 | + - name: Checkout repo |
| 86 | + uses: actions/checkout@v3 |
| 87 | + |
| 88 | + - name: Check for LICENSE.md |
| 89 | + id: license_file |
| 90 | + uses: initialstate/file-check-action@v1 |
| 91 | + with: |
| 92 | + file: "LICENSE" |
| 93 | + |
| 94 | + - name: LICENSE file Output Test |
| 95 | + run: echo ${{ steps.license_file.outputs.file_exists }} |
| 96 | + |
| 97 | + - name: LICENSE file exists with content |
| 98 | + if: steps.license_file.outputs.file_exists == 'true' |
| 99 | + run: echo LICENSE file exists! |
| 100 | + |
| 101 | + - name: LICENSE file does not exist |
| 102 | + if: steps.license_file.outputs.file_exists == 'false' |
| 103 | + run: echo LICENSE file does not exist! |
| 104 | + |
| 105 | + check-for-dependabot-file: |
| 106 | + runs-on: ubuntu-latest |
| 107 | + steps: |
| 108 | + |
| 109 | + - name: Checkout repo |
| 110 | + uses: actions/checkout@v3 |
| 111 | + |
| 112 | + - name: Check for dependabot.yml |
| 113 | + id: dependabot_file |
| 114 | + uses: initialstate/file-check-action@v1 |
| 115 | + with: |
| 116 | + file: ".github/dependabot.yml" |
| 117 | + |
| 118 | + - name: dependabot.yml file Output Test |
| 119 | + run: echo ${{ steps.dependabot_file.outputs.file_exists }} |
| 120 | + |
| 121 | + - name: dependabot file exists with content |
| 122 | + if: steps.dependabot_file.outputs.file_exists == 'true' |
| 123 | + run: echo dependabot file exists! |
| 124 | + |
| 125 | + - name: dependabot file does not exist |
| 126 | + if: steps.dependabot_file.outputs.file_exists == 'false' |
| 127 | + run: echo dependabot file does not exist! |
| 128 | + |
| 129 | + check-for-codeql-file: |
| 130 | + runs-on: ubuntu-latest |
| 131 | + steps: |
| 132 | + |
| 133 | + - name: Checkout repo |
| 134 | + uses: actions/checkout@v3 |
| 135 | + |
| 136 | + - name: Check for codeql-analysis.yml |
| 137 | + id: codeql-analysis_file |
| 138 | + uses: initialstate/file-check-action@v1 |
| 139 | + with: |
| 140 | + file: ".github/workflows/codeql-analysis.yml" |
| 141 | + |
| 142 | + - name: codeql-analysis.yml file Output Test |
| 143 | + run: echo ${{ steps.codeql-analysis_file.outputs.file_exists }} |
| 144 | + |
| 145 | + - name: codeql-analysis file exists with content |
| 146 | + if: steps.codeql-analysis_file.outputs.file_exists == 'true' |
| 147 | + run: echo codeql-analysis file exists! |
| 148 | + |
| 149 | + - name: codeql-analysis file does not exist |
| 150 | + if: steps.codeql-analysis_file.outputs.file_exists == 'false' |
| 151 | + run: echo codeql-analysis file does not exist! |
| 152 | + |
| 153 | + check-for-personal-access-token: |
| 154 | + needs: public-or-private-repo |
| 155 | + if: needs.public-or-private-repo.outputs.repostate == 'public' |
| 156 | + runs-on: ubuntu-latest |
| 157 | + steps: |
| 158 | + |
| 159 | + - name: Check for missing PERSONAL_ACCESS_TOKEN |
| 160 | + env: |
| 161 | + MY_KEY: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 162 | + if: "${{ env.MY_KEY == '' }}" |
| 163 | + uses: actions/github-script@v6 |
| 164 | + with: |
| 165 | + script: | |
| 166 | + core.setFailed('PERSONAL_ACCESS_TOKEN secret is missing. It is needed to successfully run the CLA assistant.') |
0 commit comments