Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to automate manpage updates #10650

Merged
merged 1 commit into from Feb 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/update-manpage.yml
@@ -0,0 +1,75 @@
name: Update manpage and completions

on:
nandahkrishna marked this conversation as resolved.
Show resolved Hide resolved
push:
paths:
- .github/workflows/update-manpage.yml
- README.md
- Library/Homebrew/cmd/**
- Library/Homebrew/dev-cmd/**
- Library/Homebrew/completions/**
- Library/Homebrew/manpages/**
nandahkrishna marked this conversation as resolved.
Show resolved Hide resolved
- Library/Homebrew/cli/parser.rb
- 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

- name: Update manpage and completions
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"
git reset origin/master
else
git checkout -B "$BRANCH" origin/master
BRANCH_EXISTS="1"
fi

brew man

if [ -n "$(git status --porcelain=v1 2>/dev/null)" ]; then
git add "$GITHUB_WORKSPACE/docs/Manpage.md" \
"$GITHUB_WORKSPACE/manpages/brew.1" \
"$GITHUB_WORKSPACE/completions"
git commit -m "Update manpage and completions." \
-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

- 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

- 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 }}