daily #51
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 | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" # Run every day at midnight UTC | |
| workflow_dispatch: | |
| permissions: {} # No permissions by default | |
| jobs: | |
| build-parameters: | |
| name: Prepare build parameters | |
| runs-on: ${{ github.repository_owner == 'open-edge-platform' && 'overflow' || 'ubuntu-latest' }} | |
| permissions: | |
| contents: read | |
| outputs: | |
| app_version: "${{ steps.app-version.outputs.version }}" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: app-version | |
| id: app-version | |
| uses: ./.github/actions/build-version | |
| with: | |
| version-file-path: 'application/VERSION' | |
| distrib: | |
| name: Daily Distrib Check | |
| needs: build-parameters | |
| uses: ./.github/workflows/distrib.yml | |
| permissions: | |
| contents: read | |
| packages: write # Required by nested job | |
| id-token: write # Required by nested job | |
| with: | |
| build_version: ${{ needs.build-parameters.outputs.app_version }} | |
| check-existing-issue: | |
| name: Check for existing failure issue | |
| runs-on: ${{ github.repository_owner == 'open-edge-platform' && 'overflow' || 'ubuntu-latest' }} | |
| needs: distrib | |
| if: failure() | |
| permissions: | |
| issues: read | |
| outputs: | |
| issue_exists: ${{ steps.check.outputs.issue_exists }} | |
| steps: | |
| - name: Check for existing open issue | |
| id: check | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| script: | | |
| core.info('Searching for existing open issues with labels: daily-failure, automated'); | |
| const issues = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| labels: 'daily-failure,automated', | |
| state: 'open', | |
| }); | |
| core.info(`Found ${issues.data.length} open issue(s) with matching labels`); | |
| const matchingIssues = issues.data.filter(issue => | |
| issue.title.includes('[Scheduled Check] Distrib workflow failed') | |
| ); | |
| if (matchingIssues.length > 0) { | |
| core.info(`Found ${matchingIssues.length} matching issue(s):`); | |
| for (const issue of matchingIssues) { | |
| core.info(` - #${issue.number} - "${issue.title}" (${issue.html_url})`); | |
| } | |
| } else { | |
| core.info('No existing issue found, a new one will be created'); | |
| } | |
| core.setOutput('issue_exists', matchingIssues.length > 0 ? 'true' : 'false'); | |
| create-issue-on-failure: | |
| name: Create issue on scheduled workflow failure | |
| runs-on: ${{ github.repository_owner == 'open-edge-platform' && 'overflow' || 'ubuntu-latest' }} | |
| needs: [distrib, check-existing-issue] | |
| if: failure() && needs.check-existing-issue.outputs.issue_exists == 'false' | |
| permissions: | |
| issues: write # Permission to create issues | |
| steps: | |
| - name: Create GitHub Issue | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| script: | | |
| const workflowRunUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
| const issueTitle = `[Scheduled Check] Distrib workflow failed - ${new Date().toISOString().split('T')[0]}`; | |
| const issueBody = `## Bug Report | |
| **Type:** Bug | |
| **Description:** The scheduled distrib workflow has failed. | |
| **Failed Workflow Run:** [View the failed run](${workflowRunUrl}) | |
| **Triggered at:** ${new Date().toISOString()} | |
| **Workflow:** ${context.workflow} | |
| **Run ID:** ${context.runId} | |
| Please investigate the failure and take appropriate action. | |
| `; | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: issueTitle, | |
| body: issueBody, | |
| labels: ['daily-failure', 'automated'], | |
| type: 'Bug' | |
| }); |