Merge pull request #8021 from Bo98/spdx-workflow

workflows: auto create PRs for license data updates
This commit is contained in:
Dawid Dziurla 2020-07-18 09:14:17 +02:00 committed by GitHub
commit e1fdb8117c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 12 deletions

41
.github/workflows/spdx.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: Update license data
on:
schedule:
- cron: '* */12 * * *'
jobs:
spdx:
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

View File

@ -114,11 +114,6 @@ jobs:
- name: Run brew man - name: Run brew man
run: brew man --fail-if-changed run: brew man --fail-if-changed
- name: Check for outdated license data
run: brew update-license-data --fail-if-changed
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run brew tests - name: Run brew tests
run: | run: |
# brew tests doesn't like world writable directories # brew tests doesn't like world writable directories

View File

@ -16,8 +16,8 @@ module Homebrew
Update SPDX license data in the Homebrew repository. Update SPDX license data in the Homebrew repository.
EOS EOS
switch "--fail-if-changed", switch "--fail-if-not-changed",
description: "Return a failing status code if current license data's version is different from " \ description: "Return a failing status code if current license data's version is the same as " \
"the upstream. This can be used to notify CI when the SPDX license data is out of date." "the upstream. This can be used to notify CI when the SPDX license data is out of date."
switch "--commit", switch "--commit",
description: "Commit changes to the SPDX license data." description: "Commit changes to the SPDX license data."
@ -33,7 +33,7 @@ module Homebrew
data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json" data_url = "https://raw.githubusercontent.com/spdx/license-list-data/#{latest_tag}/json/licenses.json"
curl_download(data_url, to: SPDX_PATH, partial: false) curl_download(data_url, to: SPDX_PATH, partial: false)
Homebrew.failed = !system("git", "diff", "--stat", "--exit-code", SPDX_PATH) if args.fail_if_changed? Homebrew.failed = system("git", "diff", "--stat", "--exit-code", SPDX_PATH) if args.fail_if_not_changed?
return unless args.commit? return unless args.commit?

View File

@ -1052,8 +1052,8 @@ directory.
Update SPDX license data in the Homebrew repository. Update SPDX license data in the Homebrew repository.
* `--fail-if-changed`: * `--fail-if-not-changed`:
Return a failing status code if current license data's version is different from the upstream. This can be used to notify CI when the SPDX license data is out of date. Return a failing status code if current license data's version is the same as the upstream. This can be used to notify CI when the SPDX license data is out of date.
* `--commit`: * `--commit`:
Commit changes to the SPDX license data. Commit changes to the SPDX license data.

View File

@ -1361,8 +1361,8 @@ Initialise a Git repository in the unpacked source\. This is useful for creating
Update SPDX license data in the Homebrew repository\. Update SPDX license data in the Homebrew repository\.
. .
.TP .TP
\fB\-\-fail\-if\-changed\fR \fB\-\-fail\-if\-not\-changed\fR
Return a failing status code if current license data\'s version is different from the upstream\. This can be used to notify CI when the SPDX license data is out of date\. Return a failing status code if current license data\'s version is the same as the upstream\. This can be used to notify CI when the SPDX license data is out of date\.
. .
.TP .TP
\fB\-\-commit\fR \fB\-\-commit\fR