summaryrefslogtreecommitdiffhomepage
path: root/.github/actions/setup-git-committer/action.yml
blob: 87d2f5d0d44ac4345697b7006cda640cc551eecb (plain)
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
name: "Setup Git Committer"
description: "Create app token and configure git user"
inputs:
  opencode-app-id:
    description: "OpenCode GitHub App ID"
    required: true
  opencode-app-secret:
    description: "OpenCode GitHub App private key"
    required: true
outputs:
  token:
    description: "GitHub App token"
    value: ${{ steps.apptoken.outputs.token }}
  app-slug:
    description: "GitHub App slug"
    value: ${{ steps.apptoken.outputs.app-slug }}
runs:
  using: "composite"
  steps:
    - name: Create app token
      id: apptoken
      uses: actions/create-github-app-token@v2
      with:
        app-id: ${{ inputs.opencode-app-id }}
        private-key: ${{ inputs.opencode-app-secret }}
        owner: ${{ github.repository_owner }}

    - name: Configure git user
      run: |
        slug="${{ steps.apptoken.outputs.app-slug }}"
        git config --global user.name "${slug}[bot]"
        git config --global user.email "${slug}[bot]@users.noreply.github.com"
      shell: bash

    - name: Clear checkout auth
      run: |
        git config --local --unset-all http.https://github.com/.extraheader || true
      shell: bash

    - name: Configure git remote
      run: |
        git remote set-url origin https://x-access-token:${{ steps.apptoken.outputs.token }}@github.com/${{ github.repository }}
      shell: bash