Skip to content

upstream_formula_update #16

upstream_formula_update

upstream_formula_update #16

name: Update Formula
on:
repository_dispatch:
types:
- upstream_formula_update
concurrency:
group: ${{ github.workflow }}-${{ github.event.client_payload.formula }}
env:
PYTHON_VERSION_FILE: deploy/requirements.txt
jobs:
open:
name: Sync PR
runs-on: ubuntu-latest
steps:
- uses: hmarr/[email protected]
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GIT_PAT }}
ref: ${{ github.event.repository.default_branch }}
- name: Configure git
shell: bash
run: |
set -xeuo pipefail
git config --global user.name 'robot-ci-heartex'
git config --global user.email '[email protected]'
- name: Commit version files
id: make-develop-commit
run: |
set -euo pipefail
formula_file='./Formula/${{ github.event.client_payload.formula }}.rb'
git checkout ${{ github.event.repository.default_branch }}
branch='bump-${{ github.event.client_payload.formula }}-${{ github.event.client_payload.version }}'
echo "branch=${branch}" >> $GITHUB_OUTPUT
git checkout -b "${branch}"
sed -i "0,/url /s#url .*#url \"${{ github.event.client_payload.url }}\"#" "${formula_file}"
sed -i "0,/sha256 /s#sha256 .*#sha256 \"${{ github.event.client_payload.sha256 }}\"#" "${formula_file}"
git add "${formula_file}"
git commit --message "chore: Bump ${{ github.event.client_payload.formula }}"
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
git push origin HEAD:refs/heads/${branch}
- name: Create PR
uses: actions/github-script@v7
id: create-pr
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const {repo, owner} = context.repo;
const createPullResponse = await github.rest.pulls.create({
title: 'chore: Bump ${{ github.event.client_payload.formula }}',
owner,
repo,
head: '${{ steps.make-develop-commit.outputs.branch }}',
base: '${{ github.event.repository.default_branch }}',
body: [
'Hi @${{ github.event.client_payload.actor || github.actor }}!',
'',
'This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.',
].join('\n')
});
github.rest.pulls.requestReviewers({
owner,
repo,
pull_number: createPullResponse.data.number,
reviewers: [ '${{ github.event.client_payload.actor || github.actor }}' ]
});
return createPullResponse