Skip to content

Commit 76ecd73

Browse files
committed
chore: Use custom action to commit changes in CI instead of git commit
1 parent 254b885 commit 76ecd73

5 files changed

Lines changed: 67 additions & 39 deletions

File tree

.github/workflows/check-execute-workflow-dist.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,19 @@ jobs:
3232
- name: Rebuild dist
3333
run: pnpm --filter execute-workflow build
3434

35+
- name: Stage dist changes
36+
id: stage
37+
run: |
38+
git add 'execute-workflow/dist/'
39+
if git diff --cached --quiet; then
40+
echo "has-changes=false" >> "$GITHUB_OUTPUT"
41+
else
42+
echo "has-changes=true" >> "$GITHUB_OUTPUT"
43+
fi
44+
3545
- name: Commit and push if changed
36-
uses: EndBug/add-and-commit@v10
46+
if: steps.stage.outputs.has-changes == 'true'
47+
uses: ./commit
3748
with:
38-
author_name: github-actions[bot]
39-
author_email: 41898282+github-actions[bot]@users.noreply.github.com
40-
message: "chore: rebuild execute-workflow dist [skip ci]"
41-
add: 'execute-workflow/dist/'
49+
commit-message: "chore: rebuild execute-workflow dist [skip ci]"
50+
github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}

.github/workflows/claude-md-maintenance.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,35 @@ jobs:
9797
echo "changed=false" >> "$GITHUB_OUTPUT"
9898
fi
9999
100+
- name: Prepare branch name
101+
if: steps.diff.outputs.changed == 'true'
102+
id: branch
103+
run: echo "name=chore/update-claude-md-$(date +%Y%m%d%H%M%S)" >> "$GITHUB_OUTPUT"
104+
105+
- name: Stage CLAUDE.md
106+
if: steps.diff.outputs.changed == 'true'
107+
run: git add CLAUDE.md
108+
109+
- name: Commit CLAUDE.md
110+
if: steps.diff.outputs.changed == 'true'
111+
uses: apify/workflows/commit@main
112+
with:
113+
commit-message: "docs: update CLAUDE.md [skip ci]"
114+
github-token: ${{ github.token }}
115+
branch: ${{ steps.branch.outputs.name }}
116+
create-branch: 'true'
117+
100118
- name: Create PR with updated CLAUDE.md
101119
if: steps.diff.outputs.changed == 'true'
102120
id: create-pr
103121
env:
104122
GH_TOKEN: ${{ github.token }}
105123
run: |
106-
git config user.name "github-actions[bot]"
107-
git config user.email "github-actions[bot]@users.noreply.github.com"
108-
BRANCH="chore/update-claude-md-$(date +%Y%m%d%H%M%S)"
109-
git checkout -b "$BRANCH"
110-
git add CLAUDE.md
111-
git commit -m "docs: update CLAUDE.md [skip ci]"
112-
git push origin "$BRANCH"
113124
PR_URL=$(gh pr create \
114125
--title "docs: update CLAUDE.md" \
115126
--body "Automated update of CLAUDE.md generated by the Claude MD Maintenance workflow." \
116127
--base "${{ github.ref_name }}" \
117-
--head "$BRANCH")
128+
--head "${{ steps.branch.outputs.name }}")
118129
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"
119130
120131
- name: Assign PR and request review

.github/workflows/python_bump_and_update_changelog.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
bump_and_update_changelog:
2828
runs-on: ubuntu-latest
2929
outputs:
30-
changelog_commitish: ${{ steps.commit.outputs.commit_long_sha || github.sha }}
30+
changelog_commitish: ${{ steps.commit.outputs.commit-sha || github.sha }}
3131

3232
steps:
3333
- name: Checkout repository
@@ -59,11 +59,21 @@ jobs:
5959
write-mode: overwrite
6060
contents: ${{ inputs.changelog }}
6161

62+
- name: Stage changes
63+
id: stage
64+
run: |
65+
git pull --rebase --autostash
66+
git add -A
67+
if git diff --cached --quiet; then
68+
echo "has-changes=false" >> "$GITHUB_OUTPUT"
69+
else
70+
echo "has-changes=true" >> "$GITHUB_OUTPUT"
71+
fi
72+
6273
- name: Commit changes
6374
id: commit
64-
uses: EndBug/add-and-commit@v10
75+
if: steps.stage.outputs.has-changes == 'true'
76+
uses: apify/workflows/commit@main
6577
with:
66-
author_name: github-actions[bot]
67-
author_email: 41898282+github-actions[bot]@users.noreply.github.com
68-
message: "chore(release): Update changelog and package version [skip ci]"
69-
pull: '--rebase --autostash'
78+
commit-message: "chore(release): Update changelog and package version [skip ci]"
79+
github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}

.github/workflows/sync_branches_push.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ jobs:
4545
push:
4646
runs-on: ubuntu-latest
4747
steps:
48-
- name: git
48+
- name: Merge head branch into base branch via GitHub API
49+
env:
50+
GH_TOKEN: ${{ secrets.githubToken }}
4951
run: |
5052
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
5153
HEAD_BRANCH="${GITHUB_BASE_REF}"
@@ -55,17 +57,11 @@ jobs:
5557
echo ">>> Don't know how to handle event name: ${GITHUB_EVENT_NAME}"
5658
exit 1
5759
fi
58-
mkdir repo
59-
cd repo
60-
git clone https://github-actions:${{ secrets.githubToken }}@github.com/${{ github.repository }}.git .
6160
62-
git config --global user.email "${{ inputs.gitConfigEmail }}"
63-
git config --global user.name "${{ inputs.gitConfigUsername }}"
64-
git config pull.rebase false
65-
66-
git switch ${{ inputs.baseBranch }}
67-
git pull origin ${HEAD_BRANCH} --no-edit --no-ff
68-
git push https://github-actions:${{ secrets.githubToken }}@github.com/${{ github.repository }}.git ${{ inputs.baseBranch }}:${{ inputs.baseBranch }}
61+
gh api -X POST "repos/${GITHUB_REPOSITORY}/merges" \
62+
-f base="${{ inputs.baseBranch }}" \
63+
-f head="${HEAD_BRANCH}" \
64+
-f commit_message="Merge ${HEAD_BRANCH} into ${{ inputs.baseBranch }}"
6965
7066
- name: report failure to slack
7167
if: ${{ failure() }}

git-cliff-release/README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ jobs:
4747
path: CHANGELOG.md
4848
write-mode: overwrite
4949
contents: ${{ steps.metadata.outputs.changelog }}
50+
- name: Stage changes
51+
run: git add -A
5052
- name: Commit changes
51-
uses: EndBug/add-and-commit@v10
53+
uses: apify/workflows/commit@main
5254
with:
53-
author_name: Foo
54-
author_email: foo@bar.com
55-
message: "chore(release): Update changelog and package version [skip ci]"
55+
commit-message: "chore(release): Update changelog and package version [skip ci]"
56+
github-token: ${{ secrets.GITHUB_TOKEN }}
5657
```
5758
5859
Manually trigger a release:
@@ -93,18 +94,19 @@ jobs:
9394
path: CHANGELOG.md
9495
write-mode: overwrite
9596
contents: ${{ steps.metadata.outputs.changelog }}
97+
- name: Stage changes
98+
run: git add -A
9699
- name: Commit changes
97100
id: commit
98-
uses: EndBug/add-and-commit@v10
101+
uses: apify/workflows/commit@main
99102
with:
100-
author_name: Foo
101-
author_email: foo@bar.com
102-
message: "chore(release): Update changelog and package version [skip ci]"
103+
commit-message: "chore(release): Update changelog and package version [skip ci]"
104+
github-token: ${{ secrets.GITHUB_TOKEN }}
103105
- name: Create release
104106
uses: softprops/action-gh-release@v2
105107
with:
106108
tag_name: ${{ steps.metadata.outputs.tag_name }}
107109
name: ${{ steps.metadata.outputs.version_number }}
108-
target_commitish: ${{ steps.commit.commit_long_sha || github.sha }}
110+
target_commitish: ${{ steps.commit.outputs.commit-sha || github.sha }}
109111
body: ${{ steps.metadata.outputs.release_notes }}
110112
```

0 commit comments

Comments
 (0)