Skip to content

Commit 5291c8b

Browse files
committed
chore: Use custom action to commit changes in CI instead of git commit
1 parent cc1ae18 commit 5291c8b

6 files changed

Lines changed: 49 additions & 63 deletions

File tree

.github/workflows/manual_regenerate_models.yaml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,27 @@ jobs:
104104
uv run poe generate-models
105105
fi
106106
107-
- name: Commit and push model changes
108-
id: commit
109-
uses: EndBug/add-and-commit@v10
107+
- name: Stage model changes
108+
id: stage
109+
run: |
110+
git add 'src/apify_client/_*_generated.py'
111+
if git diff --cached --quiet; then
112+
echo "has-changes=false" >> "$GITHUB_OUTPUT"
113+
else
114+
echo "has-changes=true" >> "$GITHUB_OUTPUT"
115+
fi
116+
117+
- name: Commit model changes
118+
if: steps.stage.outputs.has-changes == 'true'
119+
uses: apify/workflows/commit@v0.44.0
110120
with:
111-
add: 'src/apify_client/_*_generated.py'
112-
author_name: apify-service-account
113-
author_email: apify-service-account@users.noreply.github.com
114-
message: ${{ env.TITLE }}
115-
commit: --no-verify
116-
push: -u origin ${{ env.BRANCH }}
121+
commit-message: ${{ env.TITLE }}
122+
github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
123+
branch: ${{ env.BRANCH }}
124+
create-branch: 'true'
117125

118126
- name: Create or update PR
119-
if: steps.commit.outputs.committed == 'true'
127+
if: steps.stage.outputs.has-changes == 'true'
120128
id: pr
121129
env:
122130
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
@@ -150,7 +158,7 @@ jobs:
150158
151159
# Post a cross-repo comment on the original docs PR so reviewers know about the corresponding client-python PR.
152160
- name: Comment on apify-docs PR
153-
if: steps.commit.outputs.committed == 'true' && inputs.docs_pr_number
161+
if: steps.stage.outputs.has-changes == 'true' && inputs.docs_pr_number
154162
env:
155163
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
156164
PR_CREATED: ${{ steps.pr.outputs.created }}

.github/workflows/manual_release_beta.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,4 @@ jobs:
7272
pages: write
7373
id-token: write
7474
uses: ./.github/workflows/manual_release_docs.yaml
75-
with:
76-
# Use the ref from the changelog update to include the updated changelog.
77-
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
7875
secrets: inherit

.github/workflows/manual_release_docs.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ on:
66

77
# Runs when invoked by another workflow.
88
workflow_call:
9-
inputs:
10-
ref:
11-
description: Git ref to checkout.
12-
required: true
13-
type: string
149

1510
permissions:
1611
contents: read
@@ -35,7 +30,6 @@ jobs:
3530
uses: actions/checkout@v6
3631
with:
3732
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
38-
ref: ${{ inputs.ref || github.event.repository.default_branch }}
3933

4034
- name: Set up Node
4135
uses: actions/setup-node@v6
@@ -63,15 +57,23 @@ jobs:
6357
- name: Update docs theme
6458
run: uv run poe update-docs-theme
6559

60+
- name: Stage updated package.json and lockfile
61+
id: stage
62+
run: |
63+
git pull --rebase --autostash
64+
git add website/package.json website/pnpm-lock.yaml
65+
if git diff --cached --quiet; then
66+
echo "has-changes=false" >> "$GITHUB_OUTPUT"
67+
else
68+
echo "has-changes=true" >> "$GITHUB_OUTPUT"
69+
fi
70+
6671
- name: Commit the updated package.json and lockfile
67-
uses: EndBug/add-and-commit@v10
72+
if: steps.stage.outputs.has-changes == 'true'
73+
uses: apify/workflows/commit@v0.44.0
6874
with:
69-
add: website/package.json website/pnpm-lock.yaml
70-
message: "chore: Automatic docs theme update [skip ci]"
71-
default_author: github_actions
72-
pull: '--rebase --autostash'
73-
# `actions/checkout` detaches HEAD on SHA refs; EndBug needs a branch to push.
74-
new_branch: ${{ github.event.repository.default_branch }}
75+
commit-message: "chore: Automatic docs theme update [skip ci]"
76+
github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
7577

7678
- name: Build docs
7779
run: uv run poe build-docs

.github/workflows/manual_release_stable.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ jobs:
108108
permissions:
109109
contents: write
110110
uses: ./.github/workflows/manual_version_docs.yaml
111-
with:
112-
# Commit the version docs changes on top of the changelog commit.
113-
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
114111
secrets: inherit
115112

116113
doc_release:
@@ -121,7 +118,4 @@ jobs:
121118
pages: write
122119
id-token: write
123120
uses: ./.github/workflows/manual_release_docs.yaml
124-
with:
125-
# Commit the docs release changes on top of the version docs commit.
126-
ref: ${{ needs.version_docs.outputs.version_docs_commitish }}
127121
secrets: inherit

.github/workflows/manual_version_docs.yaml

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ on:
66

77
# Runs when invoked by another workflow.
88
workflow_call:
9-
inputs:
10-
ref:
11-
description: Git ref to checkout.
12-
required: true
13-
type: string
14-
outputs:
15-
version_docs_commitish:
16-
description: The commit SHA of the versioned docs commit.
17-
value: ${{ jobs.version_docs.outputs.version_docs_commitish }}
189

1910
concurrency:
2011
group: version-docs
@@ -31,8 +22,6 @@ jobs:
3122
version_docs:
3223
name: Version docs
3324
runs-on: ubuntu-latest
34-
outputs:
35-
version_docs_commitish: ${{ steps.resolve_commitish.outputs.commitish }}
3625
permissions:
3726
contents: write
3827

@@ -41,7 +30,6 @@ jobs:
4130
uses: actions/checkout@v6
4231
with:
4332
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
44-
ref: ${{ inputs.ref || github.event.repository.default_branch }}
4533

4634
- name: Set up Node
4735
uses: actions/setup-node@v6
@@ -104,20 +92,20 @@ jobs:
10492
uv run pnpm exec docusaurus docs:version "$MAJOR_MINOR_VERSION"
10593
uv run pnpm exec docusaurus api:version "$MAJOR_MINOR_VERSION"
10694
95+
- name: Stage versioned docs
96+
id: stage
97+
run: |
98+
git pull --rebase --autostash
99+
git add website/versioned_docs website/versioned_sidebars website/versions.json
100+
if git diff --cached --quiet; then
101+
echo "has-changes=false" >> "$GITHUB_OUTPUT"
102+
else
103+
echo "has-changes=true" >> "$GITHUB_OUTPUT"
104+
fi
105+
107106
- name: Commit and push versioned docs
108-
id: commit_versioned_docs
109-
uses: EndBug/add-and-commit@v10
107+
if: steps.stage.outputs.has-changes == 'true'
108+
uses: apify/workflows/commit@v0.44.0
110109
with:
111-
add: website/versioned_docs website/versioned_sidebars website/versions.json
112-
message: "docs: Version docs for v${{ steps.snapshot.outputs.version }} [skip ci]"
113-
default_author: github_actions
114-
pull: '--rebase --autostash'
115-
# `actions/checkout` detaches HEAD on SHA refs; EndBug needs a branch to push.
116-
new_branch: ${{ github.event.repository.default_branch }}
117-
118-
- name: Resolve output commitish
119-
id: resolve_commitish
120-
env:
121-
COMMIT_SHA: ${{ steps.commit_versioned_docs.outputs.commit_long_sha }}
122-
run: |
123-
echo "commitish=${COMMIT_SHA:-$(git rev-parse HEAD)}" >> "$GITHUB_OUTPUT"
110+
commit-message: "docs: Version docs for v${{ steps.snapshot.outputs.version }} [skip ci]"
111+
github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}

.github/workflows/on_master.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ jobs:
2525
pages: write
2626
id-token: write
2727
uses: ./.github/workflows/manual_release_docs.yaml
28-
with:
29-
# Use the same ref as the one that triggered the workflow.
30-
ref: ${{ github.ref }}
3128
secrets: inherit
3229

3330
code_checks:

0 commit comments

Comments
 (0)