Skip to content

Commit 868a8c0

Browse files
authored
Merge pull request actions#36 from nikita-bykov/move-get-go-versions-workflow
Move get-go-versions pipeline from Azure DevOps
2 parents 293cbf3 + df37e8b commit 868a8c0

2 files changed

Lines changed: 97 additions & 1 deletion

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Get Go versions
2+
on:
3+
schedule:
4+
- cron: '0 3,15 * * *'
5+
workflow_dispatch:
6+
7+
env:
8+
TOOL_NAME: "Go"
9+
defaults:
10+
run:
11+
shell: pwsh
12+
13+
jobs:
14+
find_new_versions:
15+
name: Find new versions
16+
runs-on: ubuntu-latest
17+
outputs:
18+
versions_output: ${{ steps.Get_new_versions.outputs.TOOL_VERSIONS }}
19+
steps:
20+
- uses: actions/checkout@v2
21+
with:
22+
submodules: true
23+
24+
- id: Get_new_versions
25+
name: Get new versions
26+
run: ./helpers/get-new-tool-versions/get-new-tool-versions.ps1 -ToolName ${{ env.TOOL_NAME }}
27+
28+
check_new_versions:
29+
name: Check new versions
30+
runs-on: ubuntu-latest
31+
needs: find_new_versions
32+
env:
33+
TOOL_VERSIONS: ${{needs.find_new_versions.outputs.versions_output}}
34+
steps:
35+
- uses: actions/checkout@v2
36+
with:
37+
submodules: true
38+
39+
- name: Check Versions
40+
if: env.TOOL_VERSIONS == ''
41+
run: |
42+
Write-Host "No new versions were found"
43+
Import-Module "./helpers/github/github-api.psm1"
44+
$gitHubApi = Get-GitHubApi -RepositoryFullName "$env:GITHUB_REPOSITORY" `
45+
-AccessToken "${{ secrets.PERSONAL_TOKEN }}"
46+
47+
$gitHubApi.CancelWorkflow("$env:GITHUB_RUN_ID")
48+
Start-Sleep -Seconds 60
49+
50+
- name: Send Slack notification
51+
run: |
52+
$pipelineUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID"
53+
$message = "The following versions of '${{ env.TOOL_NAME }}' are available to upload: ${{ env.TOOL_VERSIONS }}\nLink to the pipeline: $pipelineUrl"
54+
./helpers/get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" `
55+
-ToolName "${{ env.TOOL_NAME }}" `
56+
-ImageUrl "https://golang.org/lib/godoc/images/footer-gopher.jpg" `
57+
-Text "$message"
58+
trigger_builds:
59+
name: Trigger builds
60+
runs-on: ubuntu-latest
61+
needs: [find_new_versions, check_new_versions]
62+
env:
63+
TOOL_VERSIONS: ${{needs.find_new_versions.outputs.versions_output}}
64+
environment: Get Available Tools Versions - Publishing Approval
65+
steps:
66+
- uses: actions/checkout@v2
67+
with:
68+
submodules: true
69+
70+
- name: Trigger "Build go packages" workflow
71+
run:
72+
./helpers/github/run-ci-builds.ps1 -RepositoryFullName "$env:GITHUB_REPOSITORY" `
73+
-AccessToken "${{ secrets.PERSONAL_TOKEN }}" `
74+
-WorkflowFileName "build-go-packages.yml" `
75+
-WorkflowDispatchRef "main" `
76+
-ToolVersions "${{ env.TOOL_VERSIONS }}" `
77+
-PublishReleases "true"
78+
79+
check_build:
80+
name: Check build for failures
81+
runs-on: ubuntu-latest
82+
needs: [find_new_versions, check_new_versions, trigger_builds]
83+
if: failure()
84+
steps:
85+
- uses: actions/checkout@v2
86+
with:
87+
submodules: true
88+
89+
- name: Send Slack notification if build fails
90+
run: |
91+
$pipelineUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID"
92+
$message = "The build of the '${{ env.TOOL_NAME }}' detection pipeline failed :progress-error:\nLink to the pipeline: $pipelineUrl"
93+
./helpers/get-new-tool-versions/send-slack-notification.ps1 -Url "${{ secrets.SLACK_CHANNEL_URL }}" `
94+
-ToolName "${{ env.TOOL_NAME }}" `
95+
-Text "$message" `
96+
-ImageUrl "https://golang.org/lib/godoc/images/footer-gopher.jpg"

0 commit comments

Comments
 (0)