spdx.yml 1.2 KB
Newer Older
1
2
3
4
name: Update license data

on:
  schedule:
Jonathan Chang's avatar
Jonathan Chang 已提交
5
    - cron: '0 */12 * * *'
6
7
8

jobs:
  spdx:
9
    if: github.repository == 'Homebrew/brew'
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
    runs-on: ubuntu-latest
    env:
      HOMEBREW_NO_ANALYTICS: 1
      HOMEBREW_NO_AUTO_UPDATE: 1
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Configure Git
        uses: Homebrew/actions/git-user-config@master
        with:
          username: BrewTestBot

      - name: Setup Homebrew
        run: |
          HOMEBREW_REPOSITORY="$(brew --repo)"
          rm -rf "$HOMEBREW_REPOSITORY"
          ln -s "$GITHUB_WORKSPACE" "$HOMEBREW_REPOSITORY"

      - name: Update license data
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          cd "$GITHUB_WORKSPACE/Library/Homebrew"
          if brew update-license-data --commit --fail-if-not-changed; then
            SPDX_VERSION=$(jq -er .licenseListVersion data/spdx.json)
            if ! git ls-remote --exit-code --heads origin "spdx-$SPDX_VERSION"; then
              git checkout -b "spdx-$SPDX_VERSION"
              git push origin "spdx-$SPDX_VERSION"
              hub pull-request -m "$(git log -1 --format='%s')"
            fi
          fi