spdx.yml 1.7 KB
Newer Older
1
name: Update SPDX license data
2
on:
3
  push:
4
5
    paths:
      - .github/workflows/spdx.yml
6
  schedule:
Jonathan Chang's avatar
Jonathan Chang 已提交
7
    - cron: '0 */12 * * *'
8
9
jobs:
  spdx:
10
    if: github.repository == 'Homebrew/brew'
11
12
    runs-on: ubuntu-latest
    steps:
13
14
15
      - name: Set up Homebrew
        id: set-up-homebrew
        uses: Homebrew/actions/setup-homebrew@master
16

17
      - name: Configure Git user
18
19
20
21
        uses: Homebrew/actions/git-user-config@master
        with:
          username: BrewTestBot

22
23
      - name: Update SPDX license data
        id: update
24
25
26
27
28
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          cd "$GITHUB_WORKSPACE/Library/Homebrew"
29
30
31
32

          if brew update-license-data --fail-if-not-changed; then
            if ! git ls-remote --exit-code --heads origin spdx-update; then
              git checkout -B spdx-update
33
34
35
              git reset origin/master
              git add data/spdx
              git commit -m "spdx: update license data." -m "Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/spdx.yml)."
36
              echo "::set-output name=committed::true"
37
38
            fi
          fi
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

      - name: Push commits
        if: steps.update.outputs.committed == 'true'
        uses: Homebrew/actions/git-try-push@master
        with:
          token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
          branch: spdx-update

      - name: Open a pull request
        if: steps.update.outputs.committed == 'true'
        run: |
          cd "$GITHUB_WORKSPACE/Library/Homebrew"
          hub pull-request --no-edit
        env:
          GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}