-
Notifications
You must be signed in to change notification settings - Fork 381
120 lines (107 loc) · 3.31 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
name: CI
on: [create, pull_request, push]
env:
IMAGE_ID: herve76/node-binance-trader
jobs:
docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v2.3.4
- name: Docker Buildx setup
id: buildx
uses: docker/setup-buildx-action@v1.3.0
- name: Registry login
if: github.event_name != 'pull_request'
run: echo "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USER_NAME }}" --password-stdin
- name: Build
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
# Push the Docker image to the registry on git pushes that either pushed a tag or one of the following branches: [master, testing]
if [[
(
"${{ github.event_name }}" == "create"
&&
${{ startsWith(github.ref, 'refs/tags/') }} == "true"
)
||
(
"${{ github.event_name }}" == "push"
&&
${{ startsWith(github.ref, 'refs/heads/') }} == "true"
&&
(
$VERSION == "latest"
||
$VERSION == "testing"
)
)
]]
then
docker buildx build \
--cache-from=$IMAGE_ID:cache \
--cache-to=$IMAGE_ID:cache \
--push \
-t $IMAGE_ID:$VERSION \
.
else
docker buildx build \
--cache-from=$IMAGE_ID:cache \
-t $IMAGE_ID:$VERSION \
.
fi
semantic-release:
if: github.event_name != 'pull_request'
name: Semantic Release
runs-on: ubuntu-latest
needs: docker
steps:
- uses: actions/checkout@v2.3.4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2.5.3
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-assets:
if: startsWith(github.ref, 'refs/tags/')
name: Release Assets
runs-on: ubuntu-latest
needs: semantic-release
steps:
- name: Git checkout
uses: actions/checkout@v2.3.4
- name: Docker Buildx setup
id: buildx
uses: docker/setup-buildx-action@v1.3.0
- name: Build "build"
run: |
docker buildx build \
--cache-from=$IMAGE_ID:cache \
-t stage_build \
--target build \
--load \
.
docker container create --name extract stage_build
docker container cp extract:/srv/app/ ./
docker container rm -f extract
- name: Zip
uses: montudor/action-zip@v1.0.0
with:
args: zip -qq -r ./nbt.zip ./
- name: GitHub Release Asset
uses: softprops/action-gh-release@v1
with:
files: nbt.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}