-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (102 loc) · 4.79 KB
/
cd.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
name: Continuous Deployment
on:
push:
branches: [main, 'release/**']
workflow_dispatch:
env:
DH_USERNAME: ${{secrets.DOCKER_HUB_LOGIN}}
DH_TOKEN: ${{secrets.DOCKER_HUB_PWD}}
IMAGE_NAME: '2060-service-agent'
DEMO_CHATBOT_IMAGE_NAME: 'demo-chatbot-backend'
IMAGE_TAG: ${{ github.ref == 'refs/heads/main' && 'dev' || github.ref }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout service-agent
uses: actions/checkout@v4
- name: Setup node v20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: |
yarn install
- uses: codfish/semantic-release-action@v3
id: semantic
with:
branches: |
[
'release',
{
name: 'main',
prerelease: 'dev'
}
]
plugins: |
[
[
"@semantic-release/commit-analyzer",
{
"preset": "angular",
"releaseRules": [
{
"type": "refactor",
"release": "patch"
}
]
}
],
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
"@semantic-release/release-notes-generator",
]
- name: Log in to Docker Hub
if: steps.semantic.outputs.new-release-published == 'true'
run: |
echo "$DH_TOKEN" | docker login -u "$DH_USERNAME" --password-stdin
- name: Build Docker image
if: steps.semantic.outputs.new-release-published == 'true'
run: |
docker build -f Dockerfile -t $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG .
- name: Add tags to Docker image and push to Docker Hub
if: steps.semantic.outputs.new-release-published == 'true'
run: |
docker tag $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG $DH_USERNAME/$IMAGE_NAME:v${RELEASE_MAJOR}-$IMAGE_TAG
docker tag $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG $DH_USERNAME/$IMAGE_NAME:v${RELEASE_MAJOR}.${RELEASE_MINOR}-$IMAGE_TAG
docker tag $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG $DH_USERNAME/$IMAGE_NAME:v${RELEASE_MAJOR}.${RELEASE_MINOR}.${RELEASE_PATCH:0:1}-$IMAGE_TAG
docker tag $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG $DH_USERNAME/$IMAGE_NAME:v$RELEASE_VERSION
docker push $DH_USERNAME/$IMAGE_NAME:$IMAGE_TAG
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR-$IMAGE_TAG
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.$RELEASE_MINOR-$IMAGE_TAG
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.$RELEASE_MINOR.${RELEASE_PATCH:0:1}-$IMAGE_TAG
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_VERSION
- name: Add tags to Docker image and push to Docker Hub (specific to releases)
if: github.ref == 'refs/heads/release' && steps.semantic.outputs.new-release-published == 'true'
run: |
docker tag $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/} $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR
docker tag $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/} $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.$RELEASE_MINOR
docker tag $DH_USERNAME/$IMAGE_NAME:${GITHUB_REF##*/} $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.${RELEASE_MINOR}.${RELEASE_PATCH:0:1}
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.$RELEASE_MINOR
docker push $DH_USERNAME/$IMAGE_NAME:v$RELEASE_MAJOR.$RELEASE_MINOR.${RELEASE_PATCH:0:1}
- name: Build and push Chatbot Demo Docker image
if: steps.semantic.outputs.new-release-published == 'true'
run: |
docker build -f ./examples/chatbot/Dockerfile -t $DH_USERNAME/$DEMO_CHATBOT_IMAGE_NAME:$IMAGE_TAG .
docker push $DH_USERNAME/$DEMO_CHATBOT_IMAGE_NAME:$IMAGE_TAG
- name: Publish NPM packages
if: steps.semantic.outputs.new-release-published == 'true'
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn workspace @2060.io/service-agent-model version --no-git-tag-version --new-version $RELEASE_VERSION
yarn workspace @2060.io/service-agent-model publish --non-interactive
yarn workspace @2060.io/service-agent-client version --no-git-tag-version --new-version $RELEASE_VERSION
yarn workspace @2060.io/service-agent-client publish --non-interactive
yarn workspace @2060.io/service-agent-nestjs-client version --no-git-tag-version --new-version $RELEASE_VERSION
yarn workspace @2060.io/service-agent-nestjs-client publish --non-interactive