mirror of
https://github.com/SeleniumHQ/selenium.git
synced 2026-03-26 16:18:38 +00:00
* [build] add reusable commit-changes.yml workflow * Update .github/workflows/pre-release.yml
97 lines
3.1 KiB
YAML
97 lines
3.1 KiB
YAML
name: Commit Changes
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
artifact-name:
|
|
description: Name of artifact containing changes.patch
|
|
required: true
|
|
type: string
|
|
commit-message:
|
|
description: Commit message
|
|
required: true
|
|
type: string
|
|
ref:
|
|
description: Git ref to checkout
|
|
required: false
|
|
type: string
|
|
default: ''
|
|
push-branch:
|
|
description: Branch to push to (defaults to current branch, uses force push)
|
|
required: false
|
|
type: string
|
|
default: ''
|
|
outputs:
|
|
changes-committed:
|
|
description: Whether changes were committed and pushed
|
|
value: ${{ jobs.commit.outputs.committed }}
|
|
secrets:
|
|
SELENIUM_CI_TOKEN:
|
|
required: false
|
|
|
|
jobs:
|
|
commit:
|
|
name: Commit Changes
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
committed: ${{ steps.commit.outputs.committed }}
|
|
permissions:
|
|
contents: write
|
|
actions: read
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ inputs.ref || github.ref }}
|
|
token: ${{ secrets.SELENIUM_CI_TOKEN || github.token }}
|
|
- name: Download patch
|
|
id: download
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: ${{ inputs.artifact-name }}
|
|
continue-on-error: true
|
|
- name: Apply and commit
|
|
id: commit
|
|
run: |
|
|
if [ "$DOWNLOAD_OUTCOME" != "success" ]; then
|
|
echo "::notice::Artifact not found (may not have been uploaded)"
|
|
echo "committed=false" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
if [ -f changes.patch ] && [ -s changes.patch ]; then
|
|
if ! git apply --index changes.patch; then
|
|
echo "::error::Failed to apply patch"
|
|
echo "committed=false" >> "$GITHUB_OUTPUT"
|
|
exit 1
|
|
fi
|
|
git config --local user.email "selenium-ci@users.noreply.github.com"
|
|
git config --local user.name "Selenium CI Bot"
|
|
if ! git commit -m "$COMMIT_MESSAGE"; then
|
|
echo "::error::Failed to commit changes"
|
|
echo "committed=false" >> "$GITHUB_OUTPUT"
|
|
exit 1
|
|
fi
|
|
if [ -n "$PUSH_BRANCH" ]; then
|
|
if ! git push origin HEAD:"$PUSH_BRANCH" --force; then
|
|
echo "::error::Failed to push to $PUSH_BRANCH"
|
|
echo "committed=false" >> "$GITHUB_OUTPUT"
|
|
exit 1
|
|
fi
|
|
else
|
|
if ! git push; then
|
|
echo "::error::Failed to push"
|
|
echo "committed=false" >> "$GITHUB_OUTPUT"
|
|
exit 1
|
|
fi
|
|
fi
|
|
echo "::notice::Changes committed and pushed"
|
|
echo "committed=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "::notice::No changes to commit"
|
|
echo "committed=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
env:
|
|
DOWNLOAD_OUTCOME: ${{ steps.download.outcome }}
|
|
COMMIT_MESSAGE: ${{ inputs.commit-message }}
|
|
PUSH_BRANCH: ${{ inputs.push-branch }}
|