diff --git a/.github/workflows/get-xamarin-versions.yml b/.github/workflows/get-xamarin-versions.yml new file mode 100644 index 0000000..8f0c6b3 --- /dev/null +++ b/.github/workflows/get-xamarin-versions.yml @@ -0,0 +1,68 @@ +name: Get Xamarin versions +on: + schedule: + - cron: '0 8 * * THU' + workflow_dispatch: + +env: + TOOL_NAME: "Xamarin" +defaults: + run: + shell: pwsh + +jobs: + find_new_versions: + name: Find new versions + runs-on: ubuntu-latest + outputs: + versions_output: ${{ steps.Get_new_versions.outputs.TOOL_VERSIONS }} + steps: + - uses: actions/checkout@v2 + + - id: Get_new_versions + name: Get new versions + run: ./get-new-tool-versions/get-new-tool-versions.ps1 -ToolName ${{ env.TOOL_NAME }} + + check_new_versions: + name: Check new versions + runs-on: ubuntu-latest + needs: find_new_versions + env: + TOOL_VERSIONS: ${{needs.find_new_versions.outputs.versions_output}} + steps: + - uses: actions/checkout@v2 + + - name: Check Versions + if: success() && env.TOOL_VERSIONS == '' + run: | + Write-Host "No new versions were found" + Import-Module "./github/github-api.psm1" + $gitHubApi = Get-GitHubApi -RepositoryFullName "$env:GITHUB_REPOSITORY" ` + -AccessToken "${{ secrets.GITHUB_TOKEN }}" + + $gitHubApi.CancelWorkflow("$env:GITHUB_RUN_ID") + Start-Sleep -Seconds 60 + + - name: Send Slack notification + run: | + ./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` + -ToolName "${{ env.TOOL_NAME }}" ` + -ToolVersion "${{ env.TOOL_VERSIONS }}" ` + -ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4" + + check_build: + name: Check build for failures + runs-on: ubuntu-latest + needs: [find_new_versions, check_new_versions] + if: failure() + steps: + - uses: actions/checkout@v2 + + - name: Send Slack notification if build fails + run: | + $pipelineUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID" + $Message = "The build of the '${{ env.TOOL_NAME }}' detection pipeline failed :progress-error:\nLink to the pipeline: $pipelineUrl" + ./get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` + -ToolName "${{ env.TOOL_NAME }}" ` + -Text "$Message" ` + -ImageUrl "https://avatars.githubusercontent.com/u/790012?s=200&v=4"