Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 63 lines 2.4 kB view raw
1name: "Merge" 2 3on: 4 workflow_call: 5 inputs: 6 from: 7 description: Branch to merge into target branch. Can also be two branches separated by space to find the merge base between them. 8 required: true 9 type: string 10 into: 11 description: Target branch to merge into. 12 required: true 13 type: string 14 15defaults: 16 run: 17 shell: bash 18 19jobs: 20 merge: 21 runs-on: ubuntu-24.04-arm 22 steps: 23 # Use a GitHub App to create the PR so that CI gets triggered 24 # The App is scoped to Repository > Contents and Pull Requests: write for Nixpkgs 25 - uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 26 id: app-token 27 with: 28 app-id: ${{ vars.NIXPKGS_CI_APP_ID }} 29 private-key: ${{ secrets.NIXPKGS_CI_APP_PRIVATE_KEY }} 30 permission-contents: write 31 permission-pull-requests: write 32 33 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 34 35 - name: Find merge base between two branches 36 if: contains(inputs.from, ' ') 37 id: merge_base 38 env: 39 branches: ${{ inputs.from }} 40 run: | 41 # turn into bash array, split on space 42 read -ra branches <<< "$branches" 43 git fetch --shallow-since="1 month ago" origin "${branches[@]}" 44 merge_base="$(git merge-base "refs/remotes/origin/${branches[0]}" "refs/remotes/origin/${branches[1]}")" 45 echo "Found merge base: $merge_base" >&2 46 echo "merge_base=$merge_base" >> "$GITHUB_OUTPUT" 47 48 - name: ${{ inputs.from }} → ${{ inputs.into }} 49 uses: devmasx/merge-branch@854d3ac71ed1e9deb668e0074781b81fdd6e771f # 1.4.0 50 with: 51 type: now 52 from_branch: ${{ steps.merge_base.outputs.merge_base || inputs.from }} 53 target_branch: ${{ inputs.into }} 54 github_token: ${{ steps.app-token.outputs.token }} 55 56 - name: Comment on failure 57 uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 58 if: ${{ failure() }} 59 with: 60 issue-number: 105153 61 body: | 62 Periodic merge from `${{ inputs.from }}` into `${{ inputs.into }}` has [failed](https://github.com/NixOS/nixpkgs/actions/runs/${{ github.run_id }}). 63 token: ${{ steps.app-token.outputs.token }}