|
| 1 | +name: Weekly Test Workflow for Released Branches |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 6 * * 0' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + actions: write |
| 10 | + contents: read |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: weekly-release-tests |
| 14 | + cancel-in-progress: false |
| 15 | + |
| 16 | +jobs: |
| 17 | + trigger-release-branches: |
| 18 | + if: github.repository == 'valkey-io/valkey' |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Trigger weekly workflow for release branches |
| 22 | + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 |
| 23 | + with: |
| 24 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | + script: | |
| 26 | + const { owner, repo } = context.repo; |
| 27 | + const workflowId = 'daily.yml'; |
| 28 | + const workflowRef = (context.ref || '').replace('refs/heads/', '') || 'unstable'; |
| 29 | + |
| 30 | + const branches = await github.paginate(github.rest.repos.listBranches, { |
| 31 | + owner, |
| 32 | + repo, |
| 33 | + per_page: 100, |
| 34 | + }); |
| 35 | +
|
| 36 | + const MIN_MAJOR = 7; |
| 37 | + const MIN_MINOR = 2; |
| 38 | +
|
| 39 | + const releaseBranches = branches |
| 40 | + .map(branch => branch.name) |
| 41 | + .filter(name => /^\d+\.\d+$/.test(name)) |
| 42 | + .filter(name => { |
| 43 | + const [major, minor] = name.split('.').map(Number); |
| 44 | + return ( |
| 45 | + Number.isInteger(major) && |
| 46 | + Number.isInteger(minor) && |
| 47 | + (major > MIN_MAJOR || (major === MIN_MAJOR && minor >= MIN_MINOR)) |
| 48 | + ); |
| 49 | + }) |
| 50 | + .sort((a, b) => a.localeCompare(b, undefined, { numeric: true })); |
| 51 | +
|
| 52 | + if (releaseBranches.length === 0) { |
| 53 | + core.info('No release branches found matching "X.Y" pattern and >= 7.2.'); |
| 54 | + return; |
| 55 | + } |
| 56 | + |
| 57 | + core.info(`Found release branches: ${releaseBranches.join(', ')}`); |
| 58 | + core.info(`Dispatching '${workflowId}' from ref '${workflowRef}'...`); |
| 59 | + |
| 60 | + let ok = 0, fail = 0; |
| 61 | + for (const branch of releaseBranches) { |
| 62 | + try { |
| 63 | + await github.rest.actions.createWorkflowDispatch({ |
| 64 | + owner, |
| 65 | + repo, |
| 66 | + workflow_id: workflowId, |
| 67 | + ref: workflowRef, |
| 68 | + inputs: { |
| 69 | + use_git_ref: branch, |
| 70 | + }, |
| 71 | + }); |
| 72 | + core.info(`Dispatched for ${branch}`); |
| 73 | + ok++; |
| 74 | + } catch (e) { |
| 75 | + core.warning(`Failed for ${branch}: ${e.message}`); |
| 76 | + fail++; |
| 77 | + } |
| 78 | + } |
| 79 | + core.info(`Dispatch summary: ${ok} succeeded, ${fail} failed.`); |
| 80 | +
|
0 commit comments