Daily Maven Verify on All Branches #16
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: Daily Maven Verify on All Branches | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # Runs daily at midnight UTC | |
| workflow_dispatch: # Allows manual triggering of the workflow | |
| jobs: | |
| # Get the list of branches dynamically | |
| get-branches: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| branches: ${{ steps.get-branches.outputs.branches }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Fetch all branches and history | |
| - name: Get list of branches | |
| id: get-branches | |
| run: | | |
| # List all branches except HEAD and remove origin/ prefix | |
| git fetch --all | |
| branches=$(git branch -r | grep -v '\->' | grep -v HEAD | grep 'origin/sample-code' | sed 's/origin\///') | |
| echo "branches=$branches" >> $GITHUB_ENV | |
| echo "::set-output name=branches::$(echo $branches | tr '\n' ',')" | |
| # Run Maven verify on each branch in parallel | |
| verify-branches: | |
| needs: get-branches | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| branch: ${{ fromJson(needs.get-branches.outputs.branches) }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ matrix.branch }} | |
| fetch-depth: 0 # Fetch the branch | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20' | |
| - name: Setup Maven Action | |
| uses: s4u/[email protected] | |
| with: | |
| checkout-fetch-depth: 0 | |
| java-version: 17 | |
| java-distribution: temurin | |
| maven-version: 3.9.9 | |
| - name: Install Playwright dependencies | |
| run: npx playwright install-deps | |
| - name: Run Maven Verify | |
| run: | | |
| echo "Processing branch: ${{ matrix.branch }}" | |
| git checkout ${{ matrix.branch }} | |
| mvn clean verify | |
| if [ $? -ne 0 ]; then | |
| echo "Maven verify failed on branch: ${{ matrix.branch }}" | |
| else | |
| echo "Maven verify succeeded on branch: ${{ matrix.branch }}" | |
| fi |