You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
4.7 KiB
YAML
110 lines
4.7 KiB
YAML
# This reusable workflow is used by actions/*-versions repositories
|
|
# It is designed to check for new versions of a tool (Python, Node, etc.)
|
|
# The 'SLACK_CHANNEL_URL' secret must be added to the repository containing the caller workflow
|
|
# in order to publish messages to Slack.
|
|
# The 'Get Available Tools Versions - Publishing Approval' environment must be created in the repository containing the caller workflow
|
|
# The 'trigger_builds' job requires manual approval
|
|
# The GITHUB_TOKEN secret is used to cancel and trigger workflow runs
|
|
|
|
name: Get new tool versions
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
tool-name:
|
|
description: 'Name of the tool for which versions are searched'
|
|
required: true
|
|
type: string
|
|
image-url:
|
|
description: 'Tool image to be attached to Slack posts'
|
|
required: true
|
|
type: string
|
|
|
|
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@v3
|
|
with:
|
|
submodules: true
|
|
|
|
- id: Get_new_versions
|
|
name: Get new versions
|
|
run: ./helpers/get-new-tool-versions/get-new-tool-versions.ps1 -ToolName ${{ inputs.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@v3
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Check Versions
|
|
if: 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.GITHUB_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"
|
|
$message = "The following versions of '${{ inputs.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 "${{ inputs.tool-name }}" `
|
|
-ImageUrl "${{ inputs.image-url }}" `
|
|
-Text "$message"
|
|
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@v3
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Trigger "Build ${{ inputs.tool-name }} packages" workflow
|
|
run: |
|
|
$workflowFileName = "build-${{ inputs.tool-name }}-packages.yml".ToLower()
|
|
./helpers/github/run-ci-builds.ps1 -RepositoryFullName "$env:GITHUB_REPOSITORY" `
|
|
-AccessToken "${{ secrets.GITHUB_TOKEN }}" `
|
|
-WorkflowFileName "$workflowFileName" `
|
|
-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@v3
|
|
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 '${{ inputs.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 "${{ inputs.tool-name }}" `
|
|
-Text "$message" `
|
|
-ImageUrl "${{ inputs.image-url }}"
|