update-manpage.yml 2.9 KB
Newer Older
1
name: Update maintainers, manpage and completions
2
3
4
5
6
7
8
9
10
11
12

on:
  push:
    paths:
      - .github/workflows/update-manpage.yml
      - README.md
      - Library/Homebrew/cmd/**
      - Library/Homebrew/dev-cmd/**
      - Library/Homebrew/completions/**
      - Library/Homebrew/manpages/**
      - Library/Homebrew/cli/parser.rb
13
      - Library/Homebrew/completions.rb
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
      - Library/Homebrew/env_config.rb
    branches:
      - master
  schedule:
    - cron: "0 0 * * *"
  workflow_dispatch:

jobs:
  update-manpage:
    runs-on: ubuntu-latest
    if: github.repository == 'Homebrew/brew'
    steps:
      - name: Setup Homebrew
        uses: Homebrew/actions/setup-homebrew@master

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

34
35
36
37
38
      - name: Set up commit signing
        uses: Homebrew/actions/setup-commit-signing@master
        with:
          signing_key: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY }}

39
      - name: Update maintainers, manpage and completions
40
41
42
43
44
45
46
47
48
        id: update
        run: |
          git fetch origin

          BRANCH=update-manpage
          echo "::set-output name=branch::${BRANCH}"

          if git ls-remote --exit-code --heads origin "$BRANCH"; then
            git checkout "$BRANCH"
49
            git reset --hard origin/master
50
51
52
53
54
          else
            git checkout -B "$BRANCH" origin/master
            BRANCH_EXISTS="1"
          fi

55
56
57
58
          if [ "${{github.event_name}}" != "push" ]; then
            brew update-maintainers
          fi

59
          if brew man --fail-if-not-changed; then
60
61
            git add "$GITHUB_WORKSPACE/README.md" \
                    "$GITHUB_WORKSPACE/docs/Manpage.md" \
62
63
                    "$GITHUB_WORKSPACE/manpages/brew.1" \
                    "$GITHUB_WORKSPACE/completions"
64
            git commit -m "Update maintainers, manpage and completions." \
65
66
67
68
69
70
                       -m "Autogenerated by the [update-manpage](https://github.com/Homebrew/brew/blob/HEAD/.github/workflows/update-manpage.yml) workflow."
            echo "::set-output name=committed::true"
            if [ -n "$BRANCH_EXISTS" ]; then
              echo "::set-output name=pull_request::true"
            fi
          fi
71
72
        env:
          HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
nandahkrishna's avatar
nandahkrishna 已提交
73
          HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
74
75
76
77
78
79
80
81

      - name: Push commits
        if: steps.update.outputs.committed == 'true'
        uses: Homebrew/actions/git-try-push@master
        with:
          token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
          branch: ${{ steps.update.outputs.branch }}
          force: true
82
          origin_branch: "master"
83
84
85
86
87
88

      - name: Open a pull request
        if: steps.update.outputs.pull_request == 'true'
        run: hub pull-request --no-edit
        env:
          GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}