-
Notifications
You must be signed in to change notification settings - Fork 15
116 lines (98 loc) · 3.92 KB
/
Copy pathlicense-check.yml
File metadata and controls
116 lines (98 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
name: License Check
on:
workflow_call:
inputs:
repo-url:
description: "Repository URL"
required: false
type: string
bazel-target:
description: "Custom Bazel target to run (e.g., 'run //:license-check')"
required: false
default: "run //:license-check"
type: string
secrets:
dash-api-token:
description: "Eclipse DASH API Token for license verification"
required: true
jobs:
license-check:
runs-on: ${{ vars.runner_labels_ghub_standard_x64 && fromJSON(vars.runner_labels_ghub_standard_x64) || vars.REPO_RUNNER_LABELS && fromJSON(vars.REPO_RUNNER_LABELS) || 'ubuntu-latest' }}
permissions:
pull-requests: write
issues: write
steps:
- name: Checkout repository (Handle all events)
uses: actions/checkout@v4.2.2
with:
ref: ${{ github.head_ref || github.event.pull_request.head.ref || github.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- name: Setup Bazel with shared caching
uses: eclipse-score/cicd-actions/setup-bazel-cache@setup-bazel-cache/v0.0.0
with:
unique-cache-name: ${{ github.workflow }}-${{ github.job }}
- name: Run License Check via Bazel
run: |
set +e # Allow execution to continue even if a command fails
REPO_URL="${{ inputs.repo-url }}"
if [[ -z "$REPO_URL" ]]; then
REPO_URL="${{ github.server_url }}/${{ github.repository }}"
fi
OUTPUT=""
EXIT_CODE=0
# Use org secret as fallback if dash-api-token is not provided
TOKEN="${{ secrets.dash-api-token }}"
CMD="bazel ${{ inputs.bazel-target }} -- -review -project automotive.score -repo $REPO_URL -token $TOKEN"
echo "Running: $CMD"
CHECK_OUTPUT=$($CMD 2>&1)
CHECK_EXIT_CODE=$?
OUTPUT="[License Check Output]\n$CHECK_OUTPUT"
if [ $CHECK_EXIT_CODE -ne 0 ]; then
EXIT_CODE=$CHECK_EXIT_CODE
fi
echo -e "$OUTPUT" | tee license-check-output.txt
echo "exit_code=$EXIT_CODE" >> $GITHUB_ENV
echo "output<<EOF" >> $GITHUB_ENV
echo -e "$OUTPUT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Find Existing Comment
if: github.event.pull_request
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: License Check Results
- name: Comment on PR with License Check Results
if: github.event.pull_request
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
### License Check Results
🚀 The **license check** job ran with the Bazel command:
```bash
bazel ${{ inputs.bazel-target }}
```
**Status:** ${{ env.exit_code == 0 && '✅ Passed' || '⚠️ Needs Review' }}
<details>
<summary>Click to expand output</summary>
```
${{ env.output }}
```
</details>
reactions: eyes
edit-mode: replace