Skip to content

Commit 792a3ec

Browse files
authored
ci: Use custom action to commit changes in CI instead of git commit (#792)
We want to enforce commit signing for all commits in our repositories. To do that, we need to make sure even commits created by CI workflows are signed. It would be possible to sign using GPG keys, but that would require a lot of maintenance. Instead, we can commit using the GitHub GraphQL API, which automatically signs commits. This PR replaces direct `git commit` / `git push` usage (and third-party commit actions like `EndBug/add-and-commit`) with the `apify/actions/signed-commit` action, which uses the GraphQL API under the hood. As agreed on Slack, I'm also simplifying the workflows to always work on top of the default branch, rather than on a ref passed down through the input, as it should effectively be the same.
1 parent 2f97a1f commit 792a3ec

6 files changed

Lines changed: 12 additions & 55 deletions

File tree

.github/workflows/manual_regenerate_models.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,15 @@ jobs:
104104
uv run poe generate-models
105105
fi
106106
107-
- name: Commit and push model changes
107+
- name: Commit model changes
108108
id: commit
109-
uses: EndBug/add-and-commit@v10
109+
uses: apify/actions/signed-commit@v1.0.0
110110
with:
111-
add: 'src/apify_client/_*_generated.py'
112-
author_name: apify-service-account
113-
author_email: apify-service-account@users.noreply.github.com
114111
message: ${{ env.TITLE }}
115-
commit: --no-verify
116-
push: -u origin ${{ env.BRANCH }}
112+
add: 'src/apify_client/_*_generated.py'
113+
github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
114+
branch: ${{ env.BRANCH }}
115+
create-branch: 'true'
117116

118117
- name: Create or update PR
119118
if: steps.commit.outputs.committed == 'true'

.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: 3 additions & 11 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
@@ -64,14 +58,12 @@ jobs:
6458
run: uv run poe update-docs-theme
6559

6660
- name: Commit the updated package.json and lockfile
67-
uses: EndBug/add-and-commit@v10
61+
uses: apify/actions/signed-commit@v1.0.0
6862
with:
69-
add: website/package.json website/pnpm-lock.yaml
7063
message: "chore: Automatic docs theme update [skip ci]"
71-
default_author: github_actions
64+
add: 'website/package.json website/pnpm-lock.yaml'
7265
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 }}
66+
github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
7567

7668
- name: Build docs
7769
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: 3 additions & 25 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
@@ -105,19 +93,9 @@ jobs:
10593
uv run pnpm exec docusaurus api:version "$MAJOR_MINOR_VERSION"
10694
10795
- name: Commit and push versioned docs
108-
id: commit_versioned_docs
109-
uses: EndBug/add-and-commit@v10
96+
uses: apify/actions/signed-commit@v1.0.0
11097
with:
111-
add: website/versioned_docs website/versioned_sidebars website/versions.json
11298
message: "docs: Version docs for v${{ steps.snapshot.outputs.version }} [skip ci]"
113-
default_author: github_actions
99+
add: 'website/versioned_docs website/versioned_sidebars website/versions.json'
114100
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"
101+
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)