forked from prometheus-msteams/prometheus-msteams
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (81 loc) · 2.73 KB
/
release.yaml
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
name: Release Docker
on:
push:
tags:
- 'v*.*.*'
branches:
- 'master'
env:
REGISTRY: quay.io
IMAGE_NAME: prometheusmsteams/prometheus-msteams
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_QUAY_USER }}
password: ${{ secrets.DOCKER_QUAY_TOKEN }}
# build
- name: Build binaries
id: build-binary
run: |
make all
- name: Build Docker image
id: build-docker
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# tests
- name: Run tests
id: test-binary
run: |
make test
- name: Test docker image
id: test-docker
# kudos: https://stackoverflow.com/questions/63641822/run-command-with-timeout-in-github-workflow/63643845?noredirect=1#comment112574154_63643845
# keep docker image running for 2 minutes. It should timeout (error code 124).
run: |
timeout 120 docker run --rm $(echo ${{ steps.meta.outputs.tags }}|head -n1) || code=$?
if [[ $code -ne 124 ]]; then
echo "Docker image stopped with ${code}. It was expected to run forever."
exit 1;
fi
# deploy releases
- name: Create github release
id: github-release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
fail_on_unmatched_files: true
generate_release_notes: true
files: |
default-message-card.tmpl
bin/prometheus-msteams-darwin-amd64
bin/prometheus-msteams-linux-amd64
bin/prometheus-msteams-windows-amd64.exe
bin/shasum256.txt
- name: Push docker image
id: push-docker
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}