generated from IBM/template-graphql-typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (85 loc) · 2.86 KB
/
docker-build.yaml
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
name: Docker build
# Controls when the workflow will run
on:
release:
types:
- published
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to CNTK Quay
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_CNTK_USERNAME }}
password: ${{ secrets.QUAY_CNTK_TOKEN }}
- name: Setup variables
id: variables
shell: bash
run: |
LATEST_ENABLED="true"
RELEASE_TAG=${GITHUB_REF#refs/tags/}
RELEASE_TAG_ENABLED="false"
if [[ "${GITHUB_REF}" =~ refs/tags ]] && [[ "${RELEASE_TAG}" != "main" ]]; then
RELEASE_TAG_ENABLED="true"
else
RELEASE_TAG="main"
fi
echo "Release tag: ${RELEASE_TAG}"
echo "release-tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
echo "Release tag enabled: $RELEASE_TAG_ENABLED"
echo "release-tag-enabled=$RELEASE_TAG_ENABLED" >> $GITHUB_OUTPUT
echo "Latest enabled: $LATEST_ENABLED"
echo "latest-enabled=$LATEST_ENABLED" >> $GITHUB_OUTPUT
- name: Docker CNTK meta
id: cntk-meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
quay.io/ibm_ecosystem_engineering/watsonx-demo-svc
# Docker tags based on the following events/attributes
tags: |
type=raw,value=${{ steps.variables.outputs.release-tag }},enable=${{ steps.variables.outputs.release-tag-enabled }}
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.cntk-meta.outputs.tags }}
labels: ${{ steps.cntk-meta.outputs.labels }}
notify:
needs: ["build"]
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
strategy:
matrix:
repo:
- ${{ github.repository }}
steps:
- name: Repository dispatch ${{ matrix.repo }}
uses: cloud-native-toolkit/action-repository-dispatch@main
with:
notifyRepo: ${{ matrix.repo }}
eventType: released
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}