From edd8661540bd88963d3c0e2b47bf1e6c66bd2de3 Mon Sep 17 00:00:00 2001 From: "E. Lynette Rayle" Date: Mon, 13 May 2024 15:37:14 -0400 Subject: [PATCH] add workflow to fetch spdx licenses --- .github/workflows/fetch-licenses.yaml | 61 +++++++++++++++++++++++++++ .gitignore | 3 ++ 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/fetch-licenses.yaml diff --git a/.github/workflows/fetch-licenses.yaml b/.github/workflows/fetch-licenses.yaml new file mode 100644 index 0000000..3311186 --- /dev/null +++ b/.github/workflows/fetch-licenses.yaml @@ -0,0 +1,61 @@ +name: Fetch Licenses + +on: + workflow_dispatch: + inputs: + force_run: + description: 'Force run license extraction' + required: false + default: 'false' + schedule: + - cron: '0 0 * * *' # Runs at midnight ET + push: + branches: + - elr/update-licenses + +jobs: + fetch-licenses: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + with: + ref: auto-update-licenses + + - name: Checkout SPDX Repository + uses: actions/checkout@v2 + with: + repository: spdx/license-list-data + path: spdx-license-list-data + + - name: Copy Licenses + run: | + cp spdx-license-list-data/json/licenses.json cmd/licenses.json + cp spdx-license-list-data/json/exceptions.json cmd/exceptions.json + + - name: Check for changes + if: ${{ github.event.inputs.force_run == 'false' }} + run: | + git diff --exit-code -- cmd/licenses.json cmd/exceptions.json || exit 0 + + - name: Run license extraction + run: | + cd cmd + go run . extract -l -e + cd .. + + - name: Commit and push + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git commit -m "Add updated license files - $(date)" -a + git push + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + title: "Update SPDX license files" + body: "The files in this PR are auto-generated by the [fetch-licenses](./.git/workflows/fetch-license.yaml) workflow. 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/)." + branch: "auto-update-licenses" + base: "main" diff --git a/.gitignore b/.gitignore index 66fd13c..f331c44 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +# Ignore path setup by fetch-licenses workflow +spdx-license-list-data/