-
Notifications
You must be signed in to change notification settings - Fork 3
118 lines (101 loc) · 3.56 KB
/
build.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
name: Build
on:
push:
tags:
- '*.*.*'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.15
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build
run: |
make
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload binaries
id: upload-das2go
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./das2go
asset_name: das2go
asset_content_type: application/octet-stream
- name: Get the Ref
id: get-ref
uses: ankitvgupta/ref-to-tag-action@master
with:
ref: ${{ github.ref }}
head_ref: ${{ github.head_ref }}
- name: Build image
run: |
curl -ksLO https://raw.githubusercontent.com/dmwm/CMSKubernetes/master/docker/das-server/Dockerfile
curl -ksLO https://raw.githubusercontent.com/dmwm/CMSKubernetes/master/docker/das-server/run.sh
sed -i -e "s,ENV TAG=.*,ENV TAG=${{steps.get-ref.outputs.tag}},g" Dockerfile
chmod +x run.sh
docker build . --tag docker.pkg.github.com/dmwm/das2go/das2go
docker tag docker.pkg.github.com/dmwm/das2go/das2go registry.cern.ch/cmsweb/das-server
- name: Login to registry.cern.ch
uses: docker/login-action@v1.6.0
with:
registry: registry.cern.ch
username: ${{ secrets.CERN_LOGIN }}
password: ${{ secrets.CERN_TOKEN }}
- name: Publish image to registry.cern.ch
uses: docker/build-push-action@v1
with:
username: ${{ secrets.CERN_LOGIN }}
password: ${{ secrets.CERN_TOKEN }}
registry: registry.cern.ch
repository: cmsweb/das-server
tag_with_ref: true
- name: Login to Registry
uses: docker/login-action@v1.6.0
with:
registry: docker.pkg.github.com
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# - name: Publish image
# uses: docker/build-push-action@v1
# with:
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# registry: docker.pkg.github.com
# repository: dmwm/das2go/das2go
# tag_with_ref: true
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
load: true
tags: cmssw/das-server:${{steps.get-ref.outputs.tag}}
- run: docker push cmssw/das-server:${{steps.get-ref.outputs.tag}}
- name: Push new image to k8s
run: |
curl -ksLO https://raw.githubusercontent.com/vkuznet/imagebot/main/imagebot.sh
sed -i -e "s,COMMIT,${{github.sha}},g" -e "s,REPOSITORY,${{github.repository}},g" -e "s,NAMESPACE,das,g" -e "s,TAG,${{steps.get-ref.outputs.tag}},g" -e "s,IMAGE,registry.cern.ch/cmsweb/das-server,g" -e "s,SERVICE,das-server,g" -e "s,HOST,${{secrets.IMAGEBOT_URL}},g" imagebot.sh
chmod +x imagebot.sh
cat imagebot.sh
sh ./imagebot.sh