-
Notifications
You must be signed in to change notification settings - Fork 5
113 lines (106 loc) · 4.46 KB
/
build-images.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
103
104
105
106
107
108
109
110
111
112
113
name: Build Images
on:
workflow_dispatch:
inputs:
debug_enabled:
description: "Run with tmate.io debugging enabled"
required: true
type: boolean
default: false
mode:
description: "Container build mode ('dev' uses branch name image tags and 'prod' uses short sha.)"
required: true
type: choice
default: "dev"
options:
- dev
- prod
workflow_call:
inputs:
debug_enabled:
description: "Run with tmate.io debugging enabled"
required: true
type: string
default: "false"
mode:
description: "Container build mode ('dev' uses branch name image tags and 'prod' uses short sha.)"
required: true
type: string
default: "dev"
secrets:
GCP_ARTIFACT_REGISTRY_PATH:
description: "GCP Artifact Registry Path"
required: true
env:
ARGO_NAMESPACE: argo
ARGO_VERSION: v3.5.1
CONTAINER_REGISTRY_URL1: ${{ secrets.GCP_ARTIFACT_REGISTRY_PATH }}
CONTAINER_REGISTRY_URL2: "ghcr.io/pinellolab"
defaults:
run:
shell: bash
permissions:
actions: write
contents: read
jobs:
build:
runs-on: pinellolab-runners
steps:
- name: Setup Runner for Argo
run: |
cd $HOME
sudo apt-get update && sudo apt-get install -y curl
curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz
gunzip argo-linux-amd64.gz
chmod +x argo-linux-amd64
sudo mv ./argo-linux-amd64 /usr/local/bin/argo
argo version
- name: Check out repository code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@797d68864753cbceedc271349d402da4590e6302 # v4
with:
prefix: CI_
- name: Setup tmate debug session
if: ${{ inputs.debug_enabled == 'true' }}
uses: mxschmitt/action-tmate@a283f9441d2d96eb62436dc46d7014f5d357ac22 # ratchet:mxschmitt/action-tmate@v3
- name: build
run: |
echo "CI commit sha: $CI_GITHUB_SHA"
echo "CI commit PR HEAD sha: $CI_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA"
echo "commit PR HEAD sha: $GITHUB_EVENT_PULL_REQUEST_HEAD_SHA"
echo "commit PR HEAD sha short: $GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT"
echo "GitHub ref: $GITHUB_REF"
echo "CI ref: $CI_GITHUB_REF"
echo "CI ref name: $CI_GITHUB_REF_NAME"
echo "CI HEAD ref: $CI_GITHUB_HEAD_REF"
echo "Image build mode: $MODE"
echo "MODE=${{ inputs.mode }}"
MODE="${{ inputs.mode }}"
argo version --short
argo submit .argo/build.yaml \
--generate-name="${CI_GITHUB_REPOSITORY_NAME_PART_SLUG}-build-${CI_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT}-" \
-p mode="${MODE}" \
-p imageName1="${CI_GITHUB_REPOSITORY_NAME_PART_SLUG}-cpu" \
-p containerFilePath1="containers/pkg.Dockerfile" \
-p imageName2="${CI_GITHUB_REPOSITORY_NAME_PART_SLUG}-gpu" \
-p containerFilePath2="containers/gpu.Dockerfile" \
-p appName="${CI_GITHUB_REPOSITORY_NAME_PART_SLUG}" \
-p branch="${CI_GITHUB_REF_NAME}" \
-p shortSha="${CI_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT}" \
-p containerRegistryURL1="${CONTAINER_REGISTRY_URL1}" \
-p containerRegistryURL2="${CONTAINER_REGISTRY_URL2}" \
-p gitUrlNoProtocol="github.com/${CI_GITHUB_REPOSITORY_OWNER_PART_SLUG}" \
--wait --log
# build-docker-images:
# needs: [set-variables]
# if: ${{ needs.set-variables.outputs.skip_ci != 'true' && needs.set-variables.outputs.mode != 'dev' && (contains(github.event.pull_request.labels.*.name, 'build-images') || contains(github.event.pull_request.labels.*.name, 'execute-workflow') || (github.event_name == 'workflow_dispatch' && inputs.run_build_images)) }}
# uses: ./.github/workflows/build-images.yaml
# # concurrency:
# # group: bi-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}-${{ needs.set-variables.outputs.mode }}
# # cancel-in-progress: true
# secrets:
# GCP_ARTIFACT_REGISTRY_PATH: ${{ secrets.GCP_ARTIFACT_REGISTRY_PATH }}
# with:
# debug_enabled: ${{ needs.set-variables.outputs.debug }}
# mode: ${{ needs.set-variables.outputs.mode }}