From 5a83490d4f7b7da6f47d831da56b8b9b3436511e Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Mon, 23 Aug 2021 14:40:35 +0300 Subject: [PATCH 1/3] Move get-node-versions pipeline --- .github/workflows/get-node-versions.yml | 97 +++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/get-node-versions.yml diff --git a/.github/workflows/get-node-versions.yml b/.github/workflows/get-node-versions.yml new file mode 100644 index 0000000..68e67f6 --- /dev/null +++ b/.github/workflows/get-node-versions.yml @@ -0,0 +1,97 @@ +name: Get Node versions +on: + schedule: + - cron: '0 3,15 * * *' + workflow_dispatch: + +env: + TOOL_NAME: "Node" +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 + with: + submodules: true + + - id: Get_new_versions + name: Get new versions + run: ./helpers/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 + with: + submodules: true + + - name: Check Versions + if: success() && env.TOOL_VERSIONS == '' + run: | + Write-Host "No new versions were found" + Import-Module "./helpers/github/github-api.psm1" + $gitHubApi = Get-GitHubApi -RepositoryFullName "$env:GITHUB_REPOSITORY" ` + -AccessToken "${{ secrets.PERSONAL_TOKEN }}" + + $gitHubApi.CancelWorkflow("$env:GITHUB_RUN_ID") + Start-Sleep -Seconds 60 + + - name: Send Slack notification + run: | + $pipelineUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID" + ./helpers/get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` + -ToolName "${{ env.TOOL_NAME }}" ` + -ToolVersion "${{ env.TOOL_VERSIONS }}" ` + -PipelineUrl "$pipelineUrl" ` + -ImageUrl "https://nodejs.org/static/images/logo-hexagon-card.png" + + trigger_builds: + name: Trigger builds + runs-on: ubuntu-latest + needs: [find_new_versions, check_new_versions] + env: + TOOL_VERSIONS: ${{needs.find_new_versions.outputs.versions_output}} + environment: Get Available Tools Versions - Publishing Approval + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Trigger "Build Node packages" workflow + run: + ./helpers/github/run-ci-builds.ps1 -RepositoryFullName "$env:GITHUB_REPOSITORY" ` + -AccessToken "${{ secrets.PERSONAL_TOKEN }}" ` + -WorkflowFileName "build-node-packages.yml" ` + -WorkflowDispatchRef "main" ` + -ToolVersions "${{ env.TOOL_VERSIONS }}" ` + -PublishReleases "true" + + check_build: + name: Check build for failures + runs-on: ubuntu-latest + needs: [find_new_versions, check_new_versions, trigger_builds] + if: failure() + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - 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" + ./helpers/get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` + -ToolName "${{ env.TOOL_NAME }}" ` + -Text "$Message" ` + -ImageUrl "https://nodejs.org/static/images/logo-hexagon-card.png" From 6e415f531bfa52ffb96c51b701e63ffaa5f872b1 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Wed, 25 Aug 2021 15:32:15 +0300 Subject: [PATCH 2/3] Update Send Slack notification step to send a custom message --- .github/workflows/get-node-versions.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/get-node-versions.yml b/.github/workflows/get-node-versions.yml index 68e67f6..41c8236 100644 --- a/.github/workflows/get-node-versions.yml +++ b/.github/workflows/get-node-versions.yml @@ -50,11 +50,11 @@ jobs: - name: Send Slack notification run: | $pipelineUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID" + $message = "The following versions of '${{ env.TOOL_NAME }}' are available to upload: ${{ env.TOOL_VERSIONS }}\nLink to the pipeline: $pipelineUrl" ./helpers/get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` -ToolName "${{ env.TOOL_NAME }}" ` - -ToolVersion "${{ env.TOOL_VERSIONS }}" ` - -PipelineUrl "$pipelineUrl" ` - -ImageUrl "https://nodejs.org/static/images/logo-hexagon-card.png" + -ImageUrl "https://nodejs.org/static/images/logo-hexagon-card.png" ` + -Text "$message" trigger_builds: name: Trigger builds @@ -90,8 +90,8 @@ jobs: - 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" + $message = "The build of the '${{ env.TOOL_NAME }}' detection pipeline failed :progress-error:\nLink to the pipeline: $pipelineUrl" ./helpers/get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" ` -ToolName "${{ env.TOOL_NAME }}" ` - -Text "$Message" ` + -Text "$message" ` -ImageUrl "https://nodejs.org/static/images/logo-hexagon-card.png" From 5c5f144d0883cce00f5fae040879bcacddd04f27 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Thu, 26 Aug 2021 12:35:40 +0300 Subject: [PATCH 3/3] Update helpers --- helpers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers b/helpers index 46a901f..1eaa091 160000 --- a/helpers +++ b/helpers @@ -1 +1 @@ -Subproject commit 46a901fa871bc94ea6a493c1f8404214bb2e5606 +Subproject commit 1eaa091b6531cad000ee0c4585bfa97d3476b028