test #31
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: Outdated Packages | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - 'joelmut/test/package-notification' | |
| # schedule: | |
| # # Daily at 8:20 UTC | |
| # - cron: '20 8 * * *' | |
| # TODO: for testing use a manual execution. | |
| jobs: | |
| issue: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| issues: write | |
| env: | |
| REPORT_ID: "id:outdated-packages" | |
| WORKING_DIR: "botframework-sdk" | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: use node 22.x | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.x | |
| - name: check existing issue | |
| id: check-existing-issue | |
| run: | | |
| $json = gh issue list --search "in:body *${{ env.REPORT_ID }}*" --repo ${{ github.repository }} --app github-actions --state open --json id,number,body | ConvertFrom-Json | |
| if($json.body -eq $null) { | |
| echo "Could not find existing issue. Continuing..."; | |
| return; | |
| } | |
| $start = $json.body.IndexOf("<!--"); | |
| $end = $json.body.IndexOf("-->") + 3; | |
| $header = $json.body.Substring($start, $end - $start) | |
| $hash = $header.Split("hash:")[1].Split("`n")[0].Trim(); | |
| echo ISSUE_HASH=$hash >> $env:GITHUB_OUTPUT; | |
| echo ISSUE_NUMBER=$($json.number) >> $env:GITHUB_OUTPUT; | |
| # "ISSUE_HASH=$hash" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append; | |
| echo "Existing issue detected: `n - number: $($json.number)`n - hash: $hash"; | |
| shell: pwsh | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| # - name: get script from botframework-sdk | |
| # run: | | |
| # wget <botframework-sdk repo> | |
| # working-directory: ${{ WORKING_DIR }} | |
| - name: generate report | |
| run: | | |
| $json = node --experimental-transform-types report.ts | ConvertFrom-Json | |
| if($json.integrity -eq $env:ISSUE_HASH) { | |
| echo "No changes detected. Exiting..." | |
| exit 0; | |
| } | |
| "<!-- | |
| ${{ env.REPORT_ID }} | |
| hash:$($json.integrity) | |
| --> | |
| $($json.markdown)" | Out-File report.md | |
| echo "Changes detected and saved to report.md. Continuing..." | |
| echo "Changes $($env:ISSUE_HASH) ${{ steps.check-existing-issue.outputs.ISSUE_HASH }}" | |
| shell: pwsh | |
| working-directory: ${{ env.WORKING_DIR }} | |
| env: | |
| ISSUE_HASH: ${{ steps.check-existing-issue.outputs.ISSUE_HASH }} | |
| - name: create/update issue | |
| if: ${{ steps.check-existing-issue.outputs.ISSUE_HASH != '' }} | |
| run: | | |
| $content = Get-Content report.md; | |
| if($env:ISSUE_NUMBER -eq '') { | |
| gh issue create --title "Outdated packages" --body $content --repo ${{ github.repository }}; | |
| } else { | |
| gh issue edit $env:ISSUE_NUMBER --body $content --repo ${{ github.repository }}; | |
| } | |
| shell: pwsh | |
| working-directory: ${{ env.WORKING_DIR }} | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| ISSUE: ${{ github.event.issue.html_url }} | |
| ISSUE_NUMBER: ${{ steps.check-existing-issue.outputs.ISSUE_NUMBER }} | |
| # https://cli.github.com/manual/gh_issue_create | |
| # - run: | | |
| # gh issue create --title "Issue report" --body "$NUM_OPEN_ISSUES issues remaining" --repo $GITHUB_REPOSITORY | |
| # env: | |
| # GH_TOKEN: ${{ github.token }} | |
| # ISSUE: ${{ github.event.issue.html_url }} | |
| # Get outdated packages | |
| # Generate hash | |
| # Check if existing issue is open by checking the cache || title || body.hash, and save a boolean flag | |
| # If the issue exists, compare hash with the "Get outdated packages" step | |
| # If the hash is the same, exit | |
| # Generate .md report | |
| # if boolean flag is true, update the issue with the new report | |
| # if boolean flag is false, create a new issue with the report | |
| # - run: | | |
| # https://cli.github.com/manual/gh_issue_create | |
| # gh issue create --title "Issue report" --body "$NUM_OPEN_ISSUES issues remaining" --repo $GITHUB_REPOSITORY | |
| # env: | |
| # GH_TOKEN: ${{ github.token }} | |
| # ISSUE: ${{ github.event.issue.html_url }} |