|
| 1 | +name: Fetch Licenses |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + force_run: |
| 7 | + description: 'Force run license extraction' |
| 8 | + required: false |
| 9 | + default: 'false' |
| 10 | + schedule: |
| 11 | + - cron: '5 4 * * *' # Runs at 0405 UTC (0605 CET, 0005 ET, 2105 PT) |
| 12 | + |
| 13 | +jobs: |
| 14 | + fetch-licenses: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Setup Git |
| 19 | + run: | |
| 20 | + git config --global user.name "GitHub Actions" |
| 21 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 22 | + |
| 23 | + - name: Checkout this repository's auto-update-licenses branch |
| 24 | + uses: actions/checkout@v2 |
| 25 | + |
| 26 | + - name: Checkout official SPDX Repository |
| 27 | + uses: actions/checkout@v2 |
| 28 | + with: |
| 29 | + repository: spdx/license-list-data |
| 30 | + path: official-spdx-licenses # creates a tmp dir to hold the SPDX licenses from the official repo |
| 31 | + |
| 32 | + - name: Copy Licenses |
| 33 | + run: | |
| 34 | + cp official-spdx-licenses/json/licenses.json cmd/licenses.json |
| 35 | + cp official-spdx-licenses/json/exceptions.json cmd/exceptions.json |
| 36 | +
|
| 37 | + - name: Check for changes |
| 38 | + run: | |
| 39 | + git diff --exit-code -- cmd/licenses.json cmd/exceptions.json || exit 0 |
| 40 | + |
| 41 | + - name: Run license extraction |
| 42 | + run: | |
| 43 | + cd cmd |
| 44 | + echo "Current branch: $(git branch)" |
| 45 | + go run . extract -l -e |
| 46 | + cd .. |
| 47 | + git log --oneline -n 5 |
| 48 | +
|
| 49 | + - name: Create Pull Request |
| 50 | + uses: peter-evans/create-pull-request@v3 |
| 51 | + with: |
| 52 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + commit-message: Add updated license files |
| 54 | + branch: auto-update-licenses |
| 55 | + base: main |
| 56 | + title: "Update SPDX license files" |
| 57 | + body: "The files in this PR are auto-generated by the [fetch-licenses](./.git/workflows/fetch-license.yaml) workflow when it runs the `cmd/extract` script. It updates SPDX licenses based on the latest released set in the [spdx/license-list-data](https://github.com/spdx/license-list-data) repository maintained by [SPDX](https://spdx.org/licenses/). \n\nTODO: [spdxexp/spdxlicenses/license_ranges.go](./spdxexp/spdxlicenses/license_range.go) has to be updated manually." |
| 58 | + labels: 'auto-update,licenses' |
0 commit comments