summaryrefslogtreecommitdiffstats
path: root/.github/workflows/periodic-merge-24h.yml
blob: d14c482df755d3cb40f6334830801c060ca3d8cc (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# This action periodically merges base branches into staging branches.
# This is done to
#  * prevent conflicts or rather resolve them early
#  * make all potential breakage happen on the staging branch
#  * and make sure that all major rebuilds happen before the staging
#    branch get’s merged back into its base branch.

name: "Periodic Merges (24h)"

on:
  schedule:
    # * is a special character in YAML so you have to quote this string
    # Merge every 24 hours
    - cron: '0 0 * * *'
  workflow_dispatch:

permissions: {}

defaults:
  run:
    shell: bash

jobs:
  periodic-merge:
    if: github.repository_owner == 'NixOS' || github.event_name == 'workflow_dispatch'
    strategy:
      # don't fail fast, so that all pairs are tried
      fail-fast: false
      # certain branches need to be merged in order, like master->staging-next->staging
      # and disabling parallelism ensures the order of the pairs below.
      max-parallel: 1
      matrix:
        pairs:
          - from: release-26.05
            into: staging-next-26.05
          - from: staging-next-26.05
            into: staging-26.05
          - from: release-26.05
            into: staging-nixos-26.05
          - name: merge-base(master,staging) → haskell-updates
            from: master staging
            into: haskell-updates
    uses: ./.github/workflows/periodic-merge.yml
    with:
      from: ${{ matrix.pairs.from }}
      into: ${{ matrix.pairs.into }}
    name: ${{ matrix.pairs.name || format('{0} → {1}', matrix.pairs.from, matrix.pairs.into) }}
    secrets:
      NIXPKGS_CI_APP_PRIVATE_KEY: ${{ secrets.NIXPKGS_CI_APP_PRIVATE_KEY }}

  # Resets the target branch of the current haskell-updates PR.
  # This makes GitHub hide all the commits that are already part of staging and gives us a much clearer PR view.
  haskell-updates:
    needs: periodic-merge
    runs-on: ubuntu-slim
    permissions:
      pull-requests: write
    steps:
      - name: Find PR and update target branch
        uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
        with:
          script: |
            // There will at most be a single haskell-updates PR anyway, so no need to paginate.
            await Promise.all(
              (
                await github.rest.pulls.list({
                  ...context.repo,
                  state: 'open',
                  head: `${context.repo.owner}:haskell-updates`,
                })
              ).data.map((pr) =>
                github.rest.pulls.update({
                  ...context.repo,
                  pull_number: pr.number,
                  // Just updating to the same branch to trigger a UI update.
                  // This is staging most of the time, but could be staging-next in rare cases.
                  base: pr.base.ref,
                }),
              ),
            )