|
| 1 | +# |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, |
| 13 | +# software distributed under the License is distributed on an |
| 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +# KIND, either express or implied. See the License for the |
| 16 | +# specific language governing permissions and limitations |
| 17 | +# under the License. |
| 18 | +# |
| 19 | + |
| 20 | +# Workflow to be called from ASF project repository workflows to check |
| 21 | +# whether the GitHub actions references in GitHub workflows (`.github/workflows`) and |
| 22 | +# composite actions (`.github/actions`) are approved. |
| 23 | +# |
| 24 | +# The README.md of ASF Infrastructure Actions repository https://github.com/apache/infrastructure-actions |
| 25 | +# contains usage instructions. |
| 26 | +# |
| 27 | +# See: ASF Infrastructure GitHub Actions Policy: https://infra.apache.org/github-actions-policy.html |
| 28 | + |
| 29 | + |
| 30 | +name: check-project-actions.yml |
| 31 | +on: |
| 32 | + workflow_call: |
| 33 | + inputs: |
| 34 | + repository: |
| 35 | + required: false |
| 36 | + description: | |
| 37 | + Optional, the `repository` parameter for `actions/checkout`. |
| 38 | + If not specified, the default is to use the repository of the calling workflow. |
| 39 | + See https://github.com/actions/checkout?tab=readme-ov-file#usage for details. |
| 40 | + type: string |
| 41 | + ref: |
| 42 | + required: false |
| 43 | + description: | |
| 44 | + Optional, the `ref` parameter for `actions/checkout` |
| 45 | + If not specified, the default is to use the repository of the calling workflow. |
| 46 | + See https://github.com/actions/checkout?tab=readme-ov-file#usage for details. |
| 47 | + type: string |
| 48 | + fetch-depth: |
| 49 | + required: false |
| 50 | + description: | |
| 51 | + Optional, the `fetch-depth` parameter for `actions/checkout`. |
| 52 | + See https://github.com/actions/checkout?tab=readme-ov-file#usage for details. |
| 53 | + type: number |
| 54 | + default: 1 |
| 55 | + submodules: |
| 56 | + required: false |
| 57 | + description: | |
| 58 | + Optional, the `submodules` parameter for `actions/checkout`. |
| 59 | + See https://github.com/actions/checkout?tab=readme-ov-file#usage for details. |
| 60 | + type: boolean |
| 61 | + default: false |
| 62 | + |
| 63 | +jobs: |
| 64 | + check-project-actions: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + steps: |
| 67 | + - name: "Checkout apache/infrastructure-actions" |
| 68 | + uses: actions/checkout@v2 |
| 69 | + with: |
| 70 | + repository: 'apache/infrastructure-actions' |
| 71 | + ref: 'main' |
| 72 | + path: infrastructure-actions |
| 73 | + |
| 74 | + - name: "Checkout repository to be checked" |
| 75 | + uses: actions/checkout@v2 |
| 76 | + with: |
| 77 | + repository: '${{ inputs.repository }}' |
| 78 | + ref: ${{ inputs.ref }} |
| 79 | + fetch-depth: ${{ inputs.fetch-depth }} |
| 80 | + submodules: ${{ inputs.submodules }} |
| 81 | + path: repository |
| 82 | + |
| 83 | + - run: pip install ruyaml |
| 84 | + |
| 85 | + - name: Check allowed actions usage |
| 86 | + working-directory: infrastructure-actions |
| 87 | + shell: python |
| 88 | + run: | |
| 89 | + import sys |
| 90 | + sys.path.append("./gateway/") |
| 91 | +
|
| 92 | + import check_repository_actions as c |
| 93 | + c.check_project_actions('../repository', '../infrastructure-actions/approved_patterns.yml') |
0 commit comments