|
| 1 | +name: "CodeQL" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, master ] |
| 8 | + schedule: |
| 9 | + - cron: '30 5 * * 1,3' |
| 10 | + - cron: '30 5,17 * * 2,4' |
| 11 | + workflow_dispatch: |
| 12 | + workflow_run: |
| 13 | + workflows: ["Build"] |
| 14 | + types: [requested] |
| 15 | + branches: |
| 16 | + - 'releases/**' |
| 17 | + workflow_call: |
| 18 | + outputs: |
| 19 | + workflow_output1: |
| 20 | + description: "The first job output" |
| 21 | + value: ${{ jobs.my_job.outputs.job_output1 }} |
| 22 | + workflow_output2: |
| 23 | + description: "The second job output" |
| 24 | + value: ${{ jobs.my_job.outputs.job_output2 }} |
| 25 | + secrets: |
| 26 | + access-token: |
| 27 | + description: 'A token passed from the caller workflow' |
| 28 | + required: false |
| 29 | + |
| 30 | +jobs: |
| 31 | + analyze: |
| 32 | + name: Analyze (CodeQL) |
| 33 | + runs-on: ubuntu-latest |
| 34 | + # Example of job-level secrets; these secrets must exist in the repository |
| 35 | + secrets: |
| 36 | + COSMOS_KEY: ${{ secrets.COSMOS_KEY }} |
| 37 | + COSMOS_ENDPOINT: ${{ secrets.COSMOS_ENDPOINT }} |
| 38 | + strategy: |
| 39 | + fail-fast: false |
| 40 | + matrix: |
| 41 | + include: |
| 42 | + - language: c-cpp |
| 43 | + build-mode: autobuild |
| 44 | + - language: csharp |
| 45 | + build-mode: autobuild |
| 46 | + - language: go |
| 47 | + build-mode: autobuild |
| 48 | + - language: java |
| 49 | + build-mode: autobuild |
| 50 | + - language: rust |
| 51 | + build-mode: autobuild |
| 52 | + - language: swift |
| 53 | + build-mode: autobuild |
| 54 | + steps: |
| 55 | + - name: Checkout repository |
| 56 | + uses: actions/checkout@v5 |
| 57 | + |
| 58 | + - name: Initialize CodeQL |
| 59 | + uses: github/codeql-action/init@v4 |
| 60 | + with: |
| 61 | + languages: ${{ matrix.language }} |
| 62 | + build-mode: ${{ matrix.build-mode }} |
| 63 | + dependency-caching: ${{ matrix.language == 'java' }} |
| 64 | + |
| 65 | + - if: ${{ matrix.build-mode == 'manual' }} |
| 66 | + name: Build (manual) |
| 67 | + run: | |
| 68 | + make bootstrap |
| 69 | + make release |
| 70 | +
|
| 71 | + - name: Autobuild |
| 72 | + if: ${{ matrix.build-mode == 'autobuild' }} |
| 73 | + uses: github/codeql-action/autobuild@v4 |
| 74 | + |
| 75 | + - name: Perform CodeQL Analysis |
| 76 | + uses: github/codeql-action/analyze@v4 |
| 77 | + with: |
| 78 | + category: "/language:${{ matrix.language }}" |
| 79 | + |
| 80 | + test_schedule: |
| 81 | + runs-on: ubuntu-latest |
| 82 | + needs: analyze |
| 83 | + steps: |
| 84 | + - name: Not on Monday or Wednesday |
| 85 | + if: github.event.schedule != '30 5 * * 1,3' |
| 86 | + run: echo "This step will be skipped on Monday and Wednesday" |
| 87 | + |
| 88 | + - name: Every time |
| 89 | + run: echo "This step will always run" |
| 90 | + |
| 91 | + my_job: |
| 92 | + runs-on: ubuntu-latest |
| 93 | + outputs: |
| 94 | + job_output1: ${{ steps.set_outputs.outputs.out1 }} |
| 95 | + job_output2: ${{ steps.set_outputs.outputs.out2 }} |
| 96 | + steps: |
| 97 | + - name: Set example outputs |
| 98 | + id: set_outputs |
| 99 | + run: | |
| 100 | + echo "out1=done" >> $GITHUB_OUTPUT |
| 101 | + echo "out2=ok" >> $GITHUB_OUTPUT |
| 102 | +
|
| 103 | + pass-secret-to-action: |
| 104 | + runs-on: ubuntu-latest |
| 105 | + needs: my_job |
| 106 | + steps: |
| 107 | + - name: Pass the received secret to an action |
| 108 | + uses: ./.github/actions/my-action |
| 109 | + with: |
| 110 | + token: ${{ secrets.access-token }} |
| 111 | + |
| 112 | + pass-secret-to-workflow: |
| 113 | + needs: my_job |
| 114 | + uses: ./.github/workflows/my-workflow |
| 115 | + secrets: |
| 116 | + token: ${{ secrets.access-token }} |
0 commit comments