-
Notifications
You must be signed in to change notification settings - Fork 99
81 lines (72 loc) · 3.03 KB
/
cibw_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
76
77
78
79
80
81
name: Docker Image for CIBuildWheel
on:
workflow_dispatch:
inputs:
cibuildwheel_ver: {required: true, type: string, description: cibuildwheel full version string without the "v" prefix}
force_update: {required: false, type: boolean, description: Overwrite any existing image, default: false}
workflow_call:
inputs:
cibuildwheel_ver: {required: true, type: string}
force_update: {required: true, type: boolean}
pr_source_owner: {required: false, type: string}
outputs:
tag:
value: ${{vars.cibw_docker_image_override || jobs.work.outputs.tag}}
found_existing:
value: ${{jobs.work.outputs.found_existing}}
cibuildwheel_ver:
value: ${{inputs.cibuildwheel_ver}}
run-name: v${{inputs.cibuildwheel_ver}}${{inputs.force_update && ' (Force)' || ''}}
env:
ARTIFACT_NAME: arcticdb_manylinux
jobs:
work:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Calculate build script hash
run: |
function hash() { gh api /repos/$GITHUB_REPOSITORY/contents/$1?ref=$GITHUB_SHA -q .sha ; }
workflow_hash=`hash .github/workflows/cibw_docker_image.yml`
script_hash=`hash build_tooling/build_many_linux_image.sh`
image_ver="${{inputs.cibuildwheel_ver}}-$(echo $workflow_hash $script_hash | sha1sum | head -c 5)"
image_name="ghcr.io/${REPO_OWNER,,}/$ARTIFACT_NAME"
echo -e "image_ver=$image_ver\nimage_name=$image_name\noutput_tag=$image_name:$image_ver" | tee -a $GITHUB_ENV
env:
GH_TOKEN: ${{github.token}}
REPO_OWNER: ${{inputs.pr_source_owner || github.repository_owner}}
- name: Check for existing image
id: find_existing
if: ${{! inputs.force_update || vars.cibw_docker_image_override}}
run: |
if [[ -n "${{vars.cibw_docker_image_override}}" ]] ; then exit 0 ; fi
docker login ghcr.io -u token -p "${{secrets.GITHUB_TOKEN}}"
man_tag=ghcr.io/man-group/$ARTIFACT_NAME:$image_ver
if docker manifest inspect $man_tag ; then
echo "output_tag=$man_tag" | tee -a $GITHUB_ENV
else
docker manifest inspect $output_tag
fi
continue-on-error: true
# If inputs.force_update, step.outcome == skipped
# if !inputs.force_update, step.outcome == success / failure
# if cibw_docker_image_override, step.outcome == success
# So the remaining steps only need to be done if this step.outcome != success
- name: Checkout
if: steps.find_existing.outcome != 'success'
uses: actions/[email protected]
- name: Build
if: steps.find_existing.outcome != 'success'
run: build_tooling/build_many_linux_image.sh
env:
cibuildwheel_ver: ${{inputs.cibuildwheel_ver}}
- name: Push
if: steps.find_existing.outcome != 'success'
run: |
docker login ghcr.io -u token -p "${{secrets.GITHUB_TOKEN}}"
docker push -a $image_name
outputs:
tag: ${{env.output_tag}}
found_existing: ${{steps.find_existing.outcome}}