Repository navigation
68 lines (66 loc) · 2.04 KB
/
Copy pathcommit-changes.yml
File metadata and controls
68 lines (66 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Shared - 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 force push to; if unset, pushes to the checked-out branch without force
required: false
type: string
default: ''
secrets:
SELENIUM_CI_TOKEN:
required: false
jobs:
commit:
name: Commit Changes
runs-on: ubuntu-latest
permissions:
contents: write
actions: read
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.ref }}
token: ${{ secrets.SELENIUM_CI_TOKEN || github.token }}
- name: Download patch
uses: actions/download-artifact@v8
with:
pattern: ${{ inputs.artifact-name }}
merge-multiple: true
- name: Apply and commit
run: |
git config --local user.email "selenium-ci@users.noreply.github.com"
git config --local user.name "Selenium CI Bot"
if [ -s changes.patch ]; then
if git apply --reverse --check changes.patch 2>/dev/null; then
echo "::notice::Patch already applied on this branch; skipping commit and push."
exit 0
fi
git apply --index changes.patch
rm -f changes.patch
git commit -m "$COMMIT_MESSAGE"
if [ -n "$PUSH_BRANCH" ]; then
git push --force origin HEAD:"$PUSH_BRANCH"
else
git push
fi
else
echo "::notice::No changes.patch found or patch is empty; skipping commit and push."
fi
env:
COMMIT_MESSAGE: ${{ inputs.commit-message }}
PUSH_BRANCH: ${{ inputs.push-branch }}