-
-
Notifications
You must be signed in to change notification settings - Fork 44
137 lines (120 loc) · 4.85 KB
/
ci.yml
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: build-app
on:
push:
branches:
tags:
paths_ignored:
- ".github/workflows/updater.yml"
- "updater/**"
- "**.md"
pull_request:
paths_ignored:
- ".github/workflows/updater.yml"
- "updater/**"
- "**.md"
jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- name: set up go 1.23
uses: actions/setup-go@v5
with:
go-version: "1.23"
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: build and test
run: |
go test -v -race -timeout=100s -covermode=atomic -coverprofile=$GITHUB_WORKSPACE/profile.cov_tmp ./...
go build -race ./...
cat $GITHUB_WORKSPACE/profile.cov_tmp | grep -v "mocks" | grep -v "_mock" > $GITHUB_WORKSPACE/profile.cov
env:
TZ: "America/Chicago"
- name: test examples
run: |
go test -race ./...
go build -race ./...
working-directory: _examples/simplechat
env:
TZ: "America/Chicago"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61
- name: golangci-lint on example directory
uses: golangci/golangci-lint-action@v6
with:
version: v1.61
args: --config ../../.golangci.yml
working-directory: _examples/simplechat
- name: install goveralls
run: go install github.com/mattn/goveralls@latest
- name: submit coverage
run: $(go env GOPATH)/bin/goveralls -service="github" -coverprofile=$GITHUB_WORKSPACE/profile.cov
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: set up QEMU
uses: docker/setup-qemu-action@v3
- name: set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: build and deploy master image to ghcr.io and dockerhub
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push \
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \
--platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/tg-spam:${ref} -t ${USERNAME}/tg-spam:${ref} .
- name: build and deploy non-master image to ghcr.io and dockerhub
if: ${{ github.ref != 'refs/heads/master' && github.actor == 'umputun' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push \
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \
--platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/tg-spam:${ref} -t ${USERNAME}/tg-spam:${ref} .
- name: deploy tagged (latest) to ghcr.io and dockerhub
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push \
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \
--platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/tg-spam:${ref} -t ghcr.io/${USERNAME}/tg-spam:latest \
-t ${USERNAME}/tg-spam:${ref} -t ${USERNAME}/tg-spam:latest .
- name: remote deployment from master
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
UPDATER_KEY: ${{ secrets.UPDATER_KEY }}
run: curl https://radio-t.com/updater/update/tg-spam/${UPDATER_KEY}