-
Notifications
You must be signed in to change notification settings - Fork 237
133 lines (122 loc) · 4 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Build
on:
push:
tags: ["*"]
workflow_dispatch:
jobs:
build:
name: Build
runs-on: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
timeout-minutes: 15
continue-on-error: true
with:
node-version: 18.16
- name: Install bower
run: npm install -g bower
- name: Import PGP Key
run: |
export GPG_TTY=$(tty)
gpg --batch --import - <<< $PGP_KEY
env:
PGP_KEY: ${{ secrets.PGP_KEY }}
- name: Write version
id: version
run: |
V=$(sbt -no-colors --error "print version" | awk 'END{print $1}')
echo "version=$V"
echo "version=$V" >> $GITHUB_OUTPUT
- name: Build packages
run: sbt Docker/stage Debian/packageBin Rpm/packageBin Universal/packageBin cortexWithDeps/Docker/stage makeBom
- name: Move packages
run: |
mv target/rpm/RPMS/noarch/cortex*.rpm target/
mv target/universal/cortex*.zip target/
- name: Write docker tags from version
id: tags
run: |
V=${{ steps.version.outputs.version }}
if ( echo $V | grep -qi rc )
then
echo $( echo $V | sed -re 's/([0-9]+.[0-9]+.[0-9]+)-RC([0-9]+)-([0-9]+)/\1-RC\2,\1-RC\2-\3/' ) > target/tags
else
echo $( echo $V | sed -re 's/([0-9]+).([0-9]+).([0-9]+)-([0-9]+)/\1,\1.\2,\1.\2.\3,\1.\2.\3-\4,latest/' ) > target/tags
fi
echo "tags=$(cat target/tags)" >> $GITHUB_OUTPUT
- name: Build list of additional tags
id: additional-tags
uses: actions/github-script@v6
with:
script: |
core.setOutput('tags', `${{ steps.tags.outputs.tags }}`.split(",").join("\n"))
- name: Generate full docker tags
id: meta
uses: docker/metadata-action@v4
with:
images: |
name=${{ secrets.HARBOR_REGISTRY }}/thehiveproject/cortex
name=thehiveproject/cortex
tags: |
${{ steps.additional-tags.outputs.tags }}
- name: Login to Harbor
uses: docker/login-action@v2
with:
registry: ${{ secrets.HARBOR_REGISTRY }}
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push docker
uses: docker/build-push-action@v3
with:
context: target/docker/stage
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Build and push fat docker
uses: docker/build-push-action@v3
with:
context: target/docker-withdeps/target/docker/stage
push: true
tags: ${{ steps.meta.outputs.tags }}
- name: Make github release
if: github.ref_type == 'tag'
uses: "softprops/action-gh-release@v1"
id: make-release
with:
generate_release_notes: true
files: |
target/cortex*.deb
target/cortex*.rpm
target/cortex*.zip
target/cortex*.bom.xml
- name: Store artifacts
if: github.ref_type != 'tag'
uses: actions/upload-artifact@v3
with:
name: packages
path: |
target/cortex*.deb
target/cortex*.rpm
target/cortex*.zip
target/cortex*.bom.xml
retention-days: 5
notify:
needs: [ build ]
runs-on: [ ubuntu-latest ]
if: always()
steps:
- name: Slack notification
uses: Gamesight/slack-workflow-status@master
with:
repo_token: ${{secrets.GITHUB_TOKEN}}
slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}}
channel: "#ci-cortex"
name: Cortex build
include_commit_message: true
include_jobs: true