diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f7fbf0ac0f1ceb232376ffa0ef3c6af461c7a8e0..d0bf09009ffe1376a549d2e70ac30844045821ab 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,6 +4,8 @@ on: paths: - .github/workflows/docker.yml - Dockerfile + branches-ignore: + - master release: types: - published diff --git a/.github/workflows/doctor.yml b/.github/workflows/doctor.yml index 757a558d1fad0f9ef3e42b1f9fdaaca93315a39e..c7baad301f46b31c736ffad2a3dbf3fcbc0347ba 100644 --- a/.github/workflows/doctor.yml +++ b/.github/workflows/doctor.yml @@ -8,6 +8,8 @@ on: - Library/Homebrew/extend/os/diagnostic.rb - Library/Homebrew/extend/os/mac/diagnostic.rb - Library/Homebrew/os/mac/xcode.rb + branches-ignore: + - master env: HOMEBREW_DEVELOPER: 1 HOMEBREW_NO_AUTO_UPDATE: 1 diff --git a/.github/workflows/spdx.yml b/.github/workflows/spdx.yml index 4c59e7cb17050c342149c42f135f7b10306049ca..e26da352db3572f33dba9adab4474a8b317d9fcd 100644 --- a/.github/workflows/spdx.yml +++ b/.github/workflows/spdx.yml @@ -3,6 +3,8 @@ on: push: paths: - .github/workflows/spdx.yml + branches-ignore: + - master schedule: - cron: '0 */12 * * *' jobs: @@ -25,14 +27,26 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - git fetch origin master - git reset origin/master - git checkout -B spdx-update + git fetch origin + + BRANCH="spdx-update" + 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 if brew update-license-data --fail-if-not-changed; then git add "$GITHUB_WORKSPACE/Library/Homebrew/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)." echo "::set-output name=committed::true" + if [ -n "$BRANCH_EXISTS" ]; then + echo "::set-output name=pull_request::true" + fi fi - name: Push commits @@ -40,11 +54,11 @@ jobs: uses: Homebrew/actions/git-try-push@master with: token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} - branch: spdx-update + branch: ${{ steps.update.outputs.branch }} force: true - name: Open a pull request - if: steps.update.outputs.committed == 'true' + if: steps.update.outputs.pull_request == 'true' run: hub pull-request --no-edit env: GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} diff --git a/.github/workflows/tapioca.yml b/.github/workflows/tapioca.yml index b5c519fe9e68e14bc2a5768efd998d37b79b6369..a2561d18d71eb40f99ff1847ae339ca447279ad5 100644 --- a/.github/workflows/tapioca.yml +++ b/.github/workflows/tapioca.yml @@ -3,6 +3,8 @@ on: push: paths: - .github/workflows/tapioca.yml + branches-ignore: + - master schedule: - cron: '0 */12 * * *' jobs: @@ -33,9 +35,18 @@ jobs: - name: Update Tapioca definitions id: update run: | - git fetch origin master - git reset origin/master - git checkout -B tapioca-update + git fetch origin + + BRANCH="tapioca-update" + 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 # TODO: replace with `brew typecheck` cd "$GITHUB_WORKSPACE/Library/Homebrew" @@ -47,6 +58,9 @@ jobs: git add "$GITHUB_WORKSPACE/Library/Homebrew/sorbet" git commit -m "sorbet: update RBI files using Tapioca." -m "Autogenerated by [a scheduled GitHub Action](https://github.com/Homebrew/brew/blob/master/.github/workflows/tapioca.yml)." echo "::set-output name=committed::true" + if [ -n "$BRANCH_EXISTS" ]; then + echo "::set-output name=pull_request::true" + fi fi - name: Push commits @@ -54,11 +68,11 @@ jobs: uses: Homebrew/actions/git-try-push@master with: token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} - branch: tapioca-update + branch: ${{ steps.update.outputs.branch }} force: true - name: Open a pull request - if: steps.update.outputs.committed == 'true' + if: steps.update.outputs.pull_request == 'true' run: hub pull-request --no-edit env: GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}