CI - Trigger periodic full matrix tests for relevant branches #185
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI - Trigger periodic full matrix tests for relevant branches | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 3 * * *" | |
| permissions: | |
| contents: read | |
| actions: write | |
| jobs: | |
| trigger-full-matrix-tests: | |
| runs-on: ubuntu-latest | |
| if: github.repository_owner == 'valkey-io' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Fetch relevant branches | |
| id: get-branches | |
| run: | | |
| branches="main" | |
| echo branches=$branches >> "$GITHUB_OUTPUT" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Trigger full-matrix-tests workflow | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const branches = "${{ steps.get-branches.outputs.branches }}".split(" "); | |
| const workflowFile = "full-matrix-tests.yml"; | |
| const triggerWorkflow = async (branch) => { | |
| try { | |
| console.log(`Triggering workflow for branch: ${branch}`); | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: workflowFile, | |
| ref: branch, // The branch where workflow_dispatch is triggered | |
| inputs: { | |
| 'run-modules-tests': 'false', // Don't run modules tests | |
| 'run-with-macos': 'use-self-hosted' // Run on self hosted mac runners by default | |
| } | |
| }); | |
| console.log(`Successfully triggered workflow for branch: ${branch}`); | |
| } catch (error) { | |
| core.setFailed(error.message); | |
| } | |
| }; | |
| // Fire all workflow dispatch requests concurrently | |
| const promises = branches | |
| .filter(branch => branch) // Skip empty branches | |
| .map(branch => triggerWorkflow(branch)); | |
| await Promise.allSettled(promises); | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |