|
17 | 17 | types: [opened, reopened, synchronize] |
18 | 18 | merge_group: |
19 | 19 | types: [checks_requested] |
20 | | -jobs: |
21 | | - license-check: |
22 | | - runs-on: ubuntu-latest |
23 | | - permissions: |
24 | | - pull-requests: write |
25 | | - issues: write |
26 | | - steps: |
27 | | - # ------------------------------------------------------------------------------ |
28 | | - # Checkout the correct branch safely in all scenarios (PRs, forks, merges) |
29 | | - # ------------------------------------------------------------------------------ |
30 | | - # | Condition | Event Type | Checked Out Branch | |
31 | | - # |----------------------------------------|--------------------|-----------------------| |
32 | | - # | github.head_ref | pull_request_target | PR branch (source branch) | |
33 | | - # | github.event.pull_request.head.ref | pull_request | PR branch (source branch) | |
34 | | - # | github.ref | push, merge_group | The branch being pushed/merged | |
35 | | - # ------------------------------------------------------------------------------ |
36 | | - # ------------------------------------------------------------------------------ |
37 | | - # Checkout the correct repository safely in all scenarios (PRs, forks, merges) |
38 | | - # ------------------------------------------------------------------------------ |
39 | | - # | Condition | Event Type | Checked Out Repository | |
40 | | - # |------------------------------------------------|--------------------|----------------------------------| |
41 | | - # | github.event.pull_request.head.repo.full_name | pull_request | Forked repository (if PR is from a fork) | |
42 | | - # | github.repository | push, merge_group | Default repository (same repo PRs, merges, pushes) | |
43 | | - - name: Checkout repository (Handle all events) |
44 | | - |
45 | | - with: |
46 | | - ref: ${{ github.head_ref || github.event.pull_request.head.ref || github.ref }} |
47 | | - repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} |
48 | | - - name: Setup Bazel |
49 | | - uses: bazel-contrib/[email protected] |
50 | | - - name: Derive project shortname and repo URL |
51 | | - run: | |
52 | | - # Use a fixed shortname for the Dash project |
53 | | - SHORTNAME="automotive.score" |
54 | | - REPO_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" |
55 | | - echo "SHORTNAME=$SHORTNAME" >> $GITHUB_ENV |
56 | | - echo "REPO_URL=$REPO_URL" >> $GITHUB_ENV |
57 | | - - name: Run license checks |
58 | | - run: | |
59 | | - # The bash script won't fail on error. We capture the stderr and stdout and we save |
60 | | - # the exit code of the bazel command in a variable |
61 | | - # The output will also be stored in a file using the tee command |
62 | | - # We save both output and exit code in the GH actions env file |
63 | | - set +e # Ensure script does not exit on failure, even if the bazel run fails, the execution will continue |
64 | | - OUTPUT=$( |
65 | | - bazel run //docs:license.check.python -- \ |
66 | | - -review \ |
67 | | - -project "$SHORTNAME" \ |
68 | | - -repo "$REPO_URL" \ |
69 | | - -token "${{ secrets.ECLIPSE_GITLAB_API_TOKEN }}" 2>&1 |
70 | | - ) |
71 | | - EXIT_CODE=$? |
72 | | - echo "$OUTPUT" | tee license-check-output.txt |
73 | | - echo "exit_code=$EXIT_CODE" >> $GITHUB_ENV |
74 | | - echo "output<<EOF" >> $GITHUB_ENV |
75 | | - echo "$OUTPUT" >> $GITHUB_ENV |
76 | | - echo "EOF" >> $GITHUB_ENV |
77 | | - - name: Comment on PR with License Check Results |
78 | | - if: github.event.pull_request |
79 | | - uses: peter-evans/create-or-update-comment@v4 |
80 | | - with: |
81 | | - issue-number: ${{ github.event.pull_request.number }} |
82 | | - body: | |
83 | | - ### License Check Results |
84 | | - 🚀 The **license check preparation** job ran successfully. |
85 | | -
|
86 | | - **Status:** ${{ env.exit_code == 0 && '✅ Passed' || '⚠️ Needs Review' }} |
87 | 20 |
|
88 | | - <details> |
89 | | - <summary>Click to expand output</summary> |
| 21 | +permissions: |
| 22 | + pull-requests: write |
| 23 | + issues: write |
90 | 24 |
|
91 | | - ``` |
92 | | - ${{ env.output }} |
93 | | - ``` |
94 | 25 |
|
95 | | - </details> |
96 | | - reactions: eyes |
| 26 | +jobs: |
| 27 | + license-check: |
| 28 | + uses: eclipse-score/cicd-workflows/.github/workflows/license-check.yml@main |
| 29 | + with: |
| 30 | + repo-url: "${{ github.server_url }}/${{ github.repository }}" |
| 31 | + secrets: |
| 32 | + dash-api-token: ${{ secrets.ECLIPSE_GITLAB_API_TOKEN }} |
0 commit comments