mirror of
https://github.com/outbackdingo/Biohazard.git
synced 2026-01-27 10:18:27 +00:00
feat(GHA): Renovate auto rebase after PR automerge enabled
This commit is contained in:
98
.github/workflows/renovate-rebase.yaml
vendored
98
.github/workflows/renovate-rebase.yaml
vendored
@@ -35,52 +35,58 @@ jobs:
|
||||
private-key: "${{ secrets.BOT_JWT_PRIVATE_KEY }}" # $BOT_JWT_PRIVATE_KEY is generated in GitHub App main settings page, uses the X.509 private key format
|
||||
owner: "${{ github.repository_owner }}"
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
token: "${{ steps.oauth-token.outputs.token }}"
|
||||
repository: "${{ github.event.pull_request.head.repo.full_name }}"
|
||||
ref: "${{ github.event.pull_request.head.ref }}"
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Git
|
||||
- name: Update branch
|
||||
shell: bash
|
||||
run: |
|
||||
git config pull.rebase false
|
||||
git config user.name "${{ secrets.BOT_USERNAME }}[bot]"
|
||||
git config user.email "${{ secrets.BOT_USERNAME }} <${{ secrets.BOT_API_ID }}+${{ secrets.BOT_USERNAME }}[bot]@users.noreply.github.com>" # get $BOT_API_ID from `curl -s 'https://api.github.com/users/$(BOT_USERNAME)%5Bbot%5D' | yq .id`
|
||||
# echo "CURRENT_PR_SHA=$(git rev-parse --verify HEAD)" >> "${GITHUB_ENV}"
|
||||
git remote add upstream https://github.com/${{ github.event.pull_request.base.repo.full_name }}
|
||||
git pull --no-edit upstream ${{ github.event.pull_request.base.ref }}
|
||||
git log -n 1
|
||||
git status
|
||||
git reset --soft ${{ github.event.pull_request.head.sha }} # so the rev-parse in API commit gets the right SHA
|
||||
git status
|
||||
git restore --staged .
|
||||
git status
|
||||
git log -n 1
|
||||
gh api --method PUT /repos/OWNER/REPO/pulls/PULL_NUMBER/update-branch \
|
||||
--field expected_head_sha=${{ github.event.pull_request.base.sha }}"
|
||||
|
||||
- name: Commit Changes
|
||||
env:
|
||||
GITHUB_TOKEN: "${{ steps.oauth-token.outputs.token }}"
|
||||
DESTINATION_BRANCH: "${{ github.event.pull_request.head.ref }}"
|
||||
run: |
|
||||
shopt -s nullglob
|
||||
git log -n 1
|
||||
export TODAY=$( date -u '+%Y-%m-%d_%H-%M-%S' )
|
||||
export MESSAGE="chore: update ${{ github.event.pull_request.head.ref }} $TODAY"
|
||||
echo "Branch to update: $DESTINATION_BRANCH"
|
||||
git diff --name-only
|
||||
for FILE_TO_COMMIT in $(git diff --name-only);
|
||||
do
|
||||
export SHA=$( git rev-parse $DESTINATION_BRANCH:$FILE_TO_COMMIT )
|
||||
export CONTENT=$( base64 -i $FILE_TO_COMMIT )
|
||||
echo "Currently updating file: $FILE_TO_COMMIT"
|
||||
echo "File SHA: $SHA"
|
||||
gh api --method PUT /repos/${{ github.event.pull_request.head.repo.full_name }}/contents/$FILE_TO_COMMIT \
|
||||
--field message="$MESSAGE" \
|
||||
--field content=@<( base64 -i $FILE_TO_COMMIT ) \
|
||||
--field encoding="base64" \
|
||||
--field branch="$DESTINATION_BRANCH" \
|
||||
--field sha="$SHA"
|
||||
done
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
# with:
|
||||
# token: "${{ steps.oauth-token.outputs.token }}"
|
||||
# repository: "${{ github.event.pull_request.head.repo.full_name }}"
|
||||
# ref: "${{ github.event.pull_request.head.ref }}"
|
||||
# fetch-depth: 0
|
||||
#
|
||||
# - name: Git
|
||||
# shell: bash
|
||||
# run: |
|
||||
# git config pull.rebase false
|
||||
# git config user.name "${{ secrets.BOT_USERNAME }}[bot]"
|
||||
# git config user.email "${{ secrets.BOT_USERNAME }} <${{ secrets.BOT_API_ID }}+${{ secrets.BOT_USERNAME }}[bot]@users.noreply.github.com>" # get $BOT_API_ID from `curl -s 'https://api.github.com/users/$(BOT_USERNAME)%5Bbot%5D' | yq .id`
|
||||
# # echo "CURRENT_PR_SHA=$(git rev-parse --verify HEAD)" >> "${GITHUB_ENV}"
|
||||
# git remote add upstream https://github.com/${{ github.event.pull_request.base.repo.full_name }}
|
||||
# git pull --no-edit upstream ${{ github.event.pull_request.base.ref }}
|
||||
# git log -n 1
|
||||
# git status
|
||||
# git reset --soft ${{ github.event.pull_request.head.sha }} # so the rev-parse in API commit gets the right SHA
|
||||
# git status
|
||||
# git restore --staged .
|
||||
# git status
|
||||
# git log -n 1
|
||||
#
|
||||
# - name: Commit Changes
|
||||
# env:
|
||||
# GITHUB_TOKEN: "${{ steps.oauth-token.outputs.token }}"
|
||||
# DESTINATION_BRANCH: "${{ github.event.pull_request.head.ref }}"
|
||||
# run: |
|
||||
# shopt -s nullglob
|
||||
# git log -n 1
|
||||
# export TODAY=$( date -u '+%Y-%m-%d_%H-%M-%S' )
|
||||
# export MESSAGE="chore: update ${{ github.event.pull_request.head.ref }} $TODAY"
|
||||
# echo "Branch to update: $DESTINATION_BRANCH"
|
||||
# git diff --name-only
|
||||
# for FILE_TO_COMMIT in $(git diff --name-only);
|
||||
# do
|
||||
# export SHA=$( git rev-parse $DESTINATION_BRANCH:$FILE_TO_COMMIT )
|
||||
# export CONTENT=$( base64 -i $FILE_TO_COMMIT )
|
||||
# echo "Currently updating file: $FILE_TO_COMMIT"
|
||||
# echo "File SHA: $SHA"
|
||||
# gh api --method PUT /repos/${{ github.event.pull_request.head.repo.full_name }}/contents/$FILE_TO_COMMIT \
|
||||
# --field message="$MESSAGE" \
|
||||
# --field content=@<( base64 -i $FILE_TO_COMMIT ) \
|
||||
# --field encoding="base64" \
|
||||
# --field branch="$DESTINATION_BRANCH" \
|
||||
# --field sha="$SHA"
|
||||
# done
|
||||
|
||||
Reference in New Issue
Block a user