trunk.yml

 1# //.github/workflows:trunk.yml
 2#
 3# This file exists to define the steps executed for a push to the default tree.
 4# For configuring the steps that occur after a push to all other branches under
 5# the refs/heads namespace, see `//.github/workflows:presubmit.yml`.
 6---
 7name: trunk
 8
 9on:
10  push:
11    branches:
12      - master
13
14concurrency:
15  group: ${{ github.ref }}
16  cancel-in-progress: true
17
18jobs:
19  build-and-test:
20    uses: ./.github/workflows/build-and-test.yml
21    secrets: inherit
22
23  benchmark:
24    runs-on: ubuntu-latest
25    permissions:
26      contents: write
27      deployments: write
28    steps:
29      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30
31      - uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
32        with:
33          go-version: 1.24.2
34
35      - name: Run benchmark
36        run: go test -v ./... -bench=. -run=xxx -benchmem | tee output.txt
37
38      - name: Store benchmark result
39        uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 # v1.20.4
40        with:
41          tool: 'go'
42          output-file-path: output.txt
43          github-token: ${{ secrets.GITHUB_TOKEN }}
44          comment-on-alert: true
45          auto-push: true
46
47  mirror:
48    if: >
49      github.ref == 'refs/heads/master' && github.repository == 'git-bug/git-bug' && github.run_attempt == '1'
50    permissions:
51      contents: write
52    runs-on: ubuntu-latest
53    steps:
54      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
55        with:
56          fetch-depth: 0
57
58      # we use a custom deploy key in order to allow the workflow to bypass
59      # branch protection rules. without this, pushing will be rejected
60      - name: setup authentication
61        env:
62          SSH_AUTH_SOCK: /tmp/ssh-agent.sock
63        run: |
64          mkdir -p ~/.ssh
65          echo "${{ secrets.TRUNK_MIRROR_KEY }}" > ~/.ssh/id_rsa
66          chmod 0600 ~/.ssh/id_rsa
67          ssh-agent -a $SSH_AUTH_SOCK > /dev/null
68          ssh-add ~/.ssh/id_rsa
69
70      - name: push to trunk
71        env:
72          SSH_AUTH_SOCK: /tmp/ssh-agent.sock
73        run: |-
74          git config user.name git-bug-bot
75          git config user.email no-reply@git-bug.org
76          git remote set-url origin git@github.com:git-bug/git-bug.git
77          git push --atomic origin HEAD:refs/heads/trunk