This repository was archived by the owner on Jul 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
123 lines (108 loc) · 4.15 KB
/
release-weekly-build.yml
File metadata and controls
123 lines (108 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Release and Weekly Build
on:
schedule:
- cron: "0 0 * * SUN"
workflow_dispatch:
inputs:
branch:
description: 'Branch'
required: true
default: 'main'
tag:
description: 'Release Tag'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
env:
GO111MODULE: "on"
steps:
- name: Set up Go 1.15
uses: actions/setup-go@v1
with:
go-version: 1.15
id: go
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- name: Check license headers
run: make validate
- name: Run golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b . v1.27.0
./golangci-lint run
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
defaults:
run:
shell: bash
env:
GO111MODULE: "on"
GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Install Docker CLI
if: ${{ matrix.os == 'macos-latest' }}
# Only the CLI is needed to run docker-scan e2e
run: brew install docker
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
- name: Download binaries
run: make -f builder.Makefile download
- name: Build binary and run tests
env:
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
E2E_HUB_URL: ${{ secrets.E2E_HUB_URL }}
E2E_HUB_USERNAME: ${{ secrets.E2E_HUB_USERNAME }}
E2E_HUB_TOKEN: ${{ secrets.E2E_HUB_TOKEN }}
run: make TAG_NAME=${{ github.event.inputs.tag }} -f builder.Makefile build test-unit e2e
- name: Upload binary artifact
if: ${{ github.event.inputs.tag != '' }} # don't push artifacts if no tag is specified
uses: actions/upload-artifact@v2
with:
name: docker-scan-${{ matrix.os}}
path: ./bin/
- name: ON SUCCESS - Slack notification
if: ${{ success() }}
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":":heavy_check_mark: <${{ env.GITHUB_WORKFLOW_URL }}|docker scan cli plugin Weekly Build SUCCESS> on ${{ matrix.os}}"}' ${{ secrets.SLACK_WEBHOOK }}
- name: ON FAILURE - Slack notification
if: ${{ failure() }}
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":":no_entry_sign: <${{ env.GITHUB_WORKFLOW_URL }}|docker scan cli plugin Weekly Build FAILED> on ${{ matrix.os}}"}' ${{ secrets.SLACK_WEBHOOK }}
- name: ON CANCELLED - Slack notification
if: ${{ cancelled() }}
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":":bangbang: <${{ env.GITHUB_WORKFLOW_URL }}|docker scan cli plugin Weekly Build CANCELED> on ${{ matrix.os}}"}' ${{ secrets.SLACK_WEBHOOK }}
release:
runs-on: ubuntu-latest
needs: [lint, build]
if: ${{ github.event.inputs.tag != '' }} # don't release if no tag is specified
env:
E2E_TEST_AUTH_TOKEN: ${{ secrets.E2E_TEST_AUTH_TOKEN }}
GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: dist
- name: Ship it
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*/*"
prerelease: true
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.inputs.tag }}
- name: ON SUCCESS - Slack notification
if: ${{ success() }}
run: |
curl -X POST -H 'Content-type: application/json' --data '{"text":":heavy_check_mark: <${{ env.GITHUB_WORKFLOW_URL }}|docker scan cli plugin has been released> ${{ github.event.inputs.tag }}"}' ${{ secrets.SLACK_WEBHOOK }}