-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (107 loc) · 4.39 KB
/
docker-publish.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Docker-Publish
on:
schedule:
# Recompile at 00:15 UTC on Sundays
- cron: '15 0 * * 0'
push:
# Publish `main` as Docker `latest` image.
branches:
- main
# Publish `v1.2.3` tags as releases.
tags:
- v*
workflow_dispatch:
# Allow this event to be triggered in the github ui
env:
IMAGE_NAME: tensorflow-build
jobs:
get-version:
runs-on: ubuntu-latest
steps:
- id: version
run: |
# Get the latest version of tensorflow
export TENSORFLOW_COMMIT=$(git ls-remote https://github.com/tensorflow/tensorflow.git HEAD | awk '{ print substr($1, 1, 8)}'D)
echo "tensorflow_commit=${TENSORFLOW_COMMIT}" >>$GITHUB_OUTPUT
outputs:
tensorflow_commit: ${{ steps.version.outputs.tensorflow_commit }}
# Push image to GitHub Packages.
build:
needs: [get-version]
strategy:
matrix:
arch: [ { runson: ubuntu-large-disk-space, id: -amd64 } ]
#arch: [ { runson: ARM64, id: -arm64 }, { runson: ubuntu-large-disk-space, id: -amd64 } ] # disabling arm64 until we can figure out either new machines to run these on or wipe/ reset Matt's old ones -klb
runs-on: ${{ matrix.arch.runson }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: checkout code
uses: actions/checkout@v3
- name: Log into registry
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ secrets.DOCKER_USER }} --password-stdin
- name: Build image
run: |
# define the image id
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME${{matrix.arch.id}}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=${{ needs.get-version.outputs.tensorflow_commit}}
echo ARCH=${{matrix.arch.id}}
# Build the image
docker buildx build .\
--provenance false \
--build-arg COMMIT_HASH=${{ needs.get-version.outputs.tensorflow_commit}} \
--push \
--tag $IMAGE_ID:${{ needs.get-version.outputs.tensorflow_commit}} \
--file Dockerfile \
# Push the latest tag if everything build
push-latest:
needs: [get-version, build]
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
arch: [ { runson: ubuntu-latest, id: -amd64 } ]
#arch: [ { runson: ARM64, id: -arm64 }, { runson: ubuntu-latest, id: -amd64 } ]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v3
- name: Log into registry
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ secrets.DOCKER_USER }} --password-stdin
- uses: actions/setup-go@v3
with:
go-version: '>=1.18.10'
- name: Build Manifest Tool
run: |
git clone https://github.com/estesp/manifest-tool
cd manifest-tool && make binary
cd ..
- name: Build Manifest
run: |
export TF_VERSION=${{ needs.get-version.outputs.tensorflow_commit}}
# Define the base image id
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# check if image exisits
if docker manifest inspect $IMAGE_ID:$TF_VERSION > /dev/null; then
echo "Appending manifest"
docker buildx imagetools create -t $IMAGE_ID:$TF_VERSION --append $IMAGE_ID${{matrix.arch.id}}:$TF_VERSION
docker buildx imagetools create -t $IMAGE_ID:latest --append $IMAGE_ID${{matrix.arch.id}}:$TF_VERSION
else
echo "Creating new manifest"
docker buildx imagetools create -t $IMAGE_ID:$TF_VERSION $IMAGE_ID${{matrix.arch.id}}:$TF_VERSION
docker buildx imagetools create -t $IMAGE_ID:latest $IMAGE_ID${{matrix.arch.id}}:$TF_VERSION
fi
trigger-event:
needs: push-latest
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch to rebuild ABLATE dependcies
uses: peter-evans/repository-dispatch@v2
with:
repository: UBCHREST/ablate
token: ${{ secrets.TRIGGER_PAT }}
event-type: rebuild-dependencies