workflows: improve scheduled behaviour.
This commit is contained in:
parent
c6a5ea5f11
commit
9ae0208347
22
.github/workflows/spdx.yml
vendored
22
.github/workflows/spdx.yml
vendored
@ -27,14 +27,26 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
git fetch origin master
|
git fetch origin
|
||||||
git reset origin/master
|
|
||||||
git checkout -B spdx-update
|
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
|
if brew update-license-data --fail-if-not-changed; then
|
||||||
git add "$GITHUB_WORKSPACE/Library/Homebrew/data/spdx"
|
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)."
|
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"
|
echo "::set-output name=committed::true"
|
||||||
|
if [ -n "$BRANCH_EXISTS" ]; then
|
||||||
|
echo "::set-output name=pull_request::true"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Push commits
|
- name: Push commits
|
||||||
@ -42,11 +54,11 @@ jobs:
|
|||||||
uses: Homebrew/actions/git-try-push@master
|
uses: Homebrew/actions/git-try-push@master
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
||||||
branch: spdx-update
|
branch: ${{ steps.update.outputs.branch }}
|
||||||
force: true
|
force: true
|
||||||
|
|
||||||
- name: Open a pull request
|
- name: Open a pull request
|
||||||
if: steps.update.outputs.committed == 'true'
|
if: steps.update.outputs.pull_request == 'true'
|
||||||
run: hub pull-request --no-edit
|
run: hub pull-request --no-edit
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
||||||
|
|||||||
22
.github/workflows/tapioca.yml
vendored
22
.github/workflows/tapioca.yml
vendored
@ -35,9 +35,18 @@ jobs:
|
|||||||
- name: Update Tapioca definitions
|
- name: Update Tapioca definitions
|
||||||
id: update
|
id: update
|
||||||
run: |
|
run: |
|
||||||
git fetch origin master
|
git fetch origin
|
||||||
git reset origin/master
|
|
||||||
git checkout -B tapioca-update
|
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`
|
# TODO: replace with `brew typecheck`
|
||||||
cd "$GITHUB_WORKSPACE/Library/Homebrew"
|
cd "$GITHUB_WORKSPACE/Library/Homebrew"
|
||||||
@ -49,6 +58,9 @@ jobs:
|
|||||||
git add "$GITHUB_WORKSPACE/Library/Homebrew/sorbet"
|
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)."
|
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"
|
echo "::set-output name=committed::true"
|
||||||
|
if [ -n "$BRANCH_EXISTS" ]; then
|
||||||
|
echo "::set-output name=pull_request::true"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Push commits
|
- name: Push commits
|
||||||
@ -56,11 +68,11 @@ jobs:
|
|||||||
uses: Homebrew/actions/git-try-push@master
|
uses: Homebrew/actions/git-try-push@master
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
||||||
branch: tapioca-update
|
branch: ${{ steps.update.outputs.branch }}
|
||||||
force: true
|
force: true
|
||||||
|
|
||||||
- name: Open a pull request
|
- name: Open a pull request
|
||||||
if: steps.update.outputs.committed == 'true'
|
if: steps.update.outputs.pull_request == 'true'
|
||||||
run: hub pull-request --no-edit
|
run: hub pull-request --no-edit
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user