-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
48 lines (43 loc) · 1.39 KB
/
action.yml
File metadata and controls
48 lines (43 loc) · 1.39 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
name: 'Commit and Push'
description: 'Commits and pushes changes if any exist'
inputs:
github-token:
description: 'GitHub token'
required: true
commit-message:
description: 'Commit message'
required: false
default: 'Auto commit'
user-email:
description: 'Git user.email'
required: false
default: 'action@github.com'
user-name:
description: 'Git user.name'
required: false
default: 'GitHub Action'
runs:
using: 'composite'
steps:
- name: Commit and Push
run: |
if [ -n "$(git status --porcelain)" ]; then
git config --local user.email "$USER_EMAIL"
git config --local user.name "$USER_NAME"
git remote set-url origin https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY
git add -A
git commit -m "$COMMIT_MESSAGE"
git pull --rebase origin $BRANCH_NAME
git push origin HEAD:$BRANCH_NAME
else
echo "No changes to commit."
fi
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
GITHUB_REPOSITORY: ${{ github.repository }}
COMMIT_MESSAGE: ${{ inputs.commit-message }}
# Push to the source branch (head_ref for PRs, ref_name for direct pushes)
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
USER_EMAIL: ${{ inputs.user-email }}
USER_NAME: ${{ inputs.user-name }}