[507a54]: / .github / workflows / docker_push_chatbot.yml

Download this file

94 lines (81 with data), 3.1 kB

 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
# To-Do: Make test case and add it the workflow pipeline
name: Chatbot server CI
# Only trigger the workflow in the case of a version tag pushed
on:
push:
tags:
- "v*.*.*"
# branches:
# - 'rasa'
# pull_request:
# branches:
# - 'rasa'
# Workflow can be run manually with REST API and 'ref' as request body parameters.
# The reference should be tag name,
# Reference: https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
workflow_dispatch:
jobs:
build:
name: Push chatbot server Docker image to Docker Hub
# Builds run on latest Ubuntu instance
runs-on: ubuntu-latest
steps:
# Checks-out repository under $GITHUB_WORKSPACE, so the job can access it
# We don't use 're: rasa' in this step, refs should be the tags
- name: Check Out Repo
uses: actions/checkout@v2
# Build a cache, to reduce build time and number of pulls to the DockerHub
# Reference: https://docs.docker.com/ci-cd/github-actions/#optimizing-the-workflow
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# Loging to the DockerHub with docker username and access token stored in Github
- name: Login to DockerHub
# Run this step only if event is tag pushing
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# Store docker tags (ref tag) and labels
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
medbot/nabot_chatbot
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
# Use BuildKit as a Builder
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
# Store the github repository tag
- uses: actions/checkout@v2
- name: Set output
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
# Build and push image
- name: Build and push action server
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./production/rasa-server
file: ./production/rasa-server/Dockerfile
build-args: ${{ steps.vars.outputs.tag }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Give the digest of Docker image
- name: Chabot server image digest
run: echo ${{ steps.docker_build.outputs.digest }}