-
Notifications
You must be signed in to change notification settings - Fork 134
76 lines (69 loc) · 2.37 KB
/
template-build-docker-x64.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
name: build-docker-x64
on:
workflow_call:
inputs:
ref:
required: true
type: string
default: 'refs/heads/dev'
new_version:
required: true
type: string
default: ''
runs-on:
required: false
type: string
default: 'ubuntu-latest'
description: 'The runner to use for this job'
cmake-extra-flags:
required: false
type: string
default: ''
description: 'The cmake flags to use for this job'
tags:
required: false
type: string
default: 'menloltd/cortex:latest'
description: 'The tags to use for docker build and push'
jobs:
build-docker-x64:
runs-on: ${{ inputs.runs-on }}
permissions:
contents: write
steps:
- name: Getting the repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
submodules: 'recursive'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
push: true
tags: ${{ inputs.tags }}
build-args: |
CORTEX_CPP_VERSION=${{ inputs.new_version }}
CMAKE_EXTRA_FLAGS=${{ inputs.cmake-extra-flags }}
- name: Update Docker Hub overview
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
README_CONTENT=$(cat docker/README.md | tr -d '\r' | sed ':a;N;$!ba;s/\n/\\n/g')
JSON_PAYLOAD=$(printf '{"full_description": "%s"}' "$README_CONTENT")
curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: JWT $(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'"$DOCKERHUB_USERNAME"'", "password": "'"$DOCKERHUB_TOKEN"'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)" \
-d "{\"full_description\": \"$JSON_PAYLOAD\"}" \
https://hub.docker.com/v2/repositories/menloltd/cortex/