-
Notifications
You must be signed in to change notification settings - Fork 90
75 lines (60 loc) · 2.29 KB
/
build-docker-image.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
# build docker image and push to docker hub
# note: this won't work because the cross-platform build takes around 10h,
# but github limits us to 6h.
# so need to build it locally and push to docker hub.
# see Dockerfile for instructions.
# needs github secrets set for -
# DOCKERHUB_USERNAME - ie mtconnect
# DOCKERHUB_TOKEN - token for that account
# Set VERSION below before building.
# See CMakeLists.txt for the current version.
# Note: this will tag the image with that version, as well as 'latest'.
name: Build Docker image
env:
PLATFORMS: linux/amd64,linux/arm64
# when to run workflow
on:
# # run on push or pull request events for the master branch
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
# allows you to run this workflow manually from the actions tab
workflow_dispatch:
# a workflow run has one or more jobs that can run sequentially or in parallel
jobs:
# this workflow contains a single job called "build"
build:
# the type of runner that the job will run on
runs-on: ubuntu-latest
# steps represent a sequence of tasks that will be executed as part of the job
steps:
# checks-out your repository under $GITHUB_WORKSPACE
# see https://github.com/actions/checkout
- name: Checkout Agent
uses: actions/checkout@v3
# the QEMU emulator lets us build for arm processors also
# see https://github.com/docker/setup-qemu-action
- name: Set up QEMU emulator
uses: docker/setup-qemu-action@v1
# see https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# see https://github.com/docker/build-push-action
- name: Build image and push to DockerHub
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: ${{ env.PLATFORMS }}
# docker hub user/repo:tag
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/agent:latest
${{ secrets.DOCKERHUB_USERNAME }}/agent:${{ github.ref_name }}
# push to docker hub
push: true