-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (109 loc) · 4.31 KB
/
Copy pathdev-build.yml
File metadata and controls
123 lines (109 loc) · 4.31 KB
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
### This is a custom dev-build.yml workflow for the ###
### timdex-embeddings-dev app repository. It is customized in order to ###
### support parallel builds for amd64 and/or arm64 for AWS Batch compute ###
### environments that have GPUs and compute environments that do NOT have ###
### GPUs. ###
name: Dev Container Build and Deploy
on:
workflow_dispatch:
pull_request:
branches:
- main
paths-ignore:
- '.github/**'
- 'docs/**'
- 'tests/**'
- 'README.md'
permissions:
id-token: write
contents: read
env:
AWS_REGION: "us-east-1"
GHA_ROLE: "timdex-embeddings-gha-dev"
REPOSITORY: "timdex-embeddings-dev"
jobs:
choose-runners:
# This line adds a check for the user which is requesting the PR. As long as its not dependabot, we go ahead and run it.
if: ${{ github.triggering_actor != 'dependabot[bot]' }}
name: Determine Runner architecture from .aws-architecture file
runs-on: ubuntu-latest
outputs:
gpu_arch: ${{ steps.out.outputs.gpu_arch }}
cpu_arch: ${{ steps.out.outputs.cpu_arch }}
steps:
- uses: actions/checkout@v5
- id: out
run: |
GPU_ARCH=$(jq -r '.gpu // "linux/amd64"' .aws-architecture)
CPU_ARCH=$(jq -r '.cpu // "linux/amd64"' .aws-architecture)
echo "gpu_arch=$GPU_ARCH" >> $GITHUB_OUTPUT
echo "cpu_arch=$CPU_ARCH" >> $GITHUB_OUTPUT
build:
# This line adds a check for the user which is requesting the PR. As long as its not dependabot, we go ahead and run it.
if: ${{ github.triggering_actor != 'dependabot[bot]' }}
name: Build ${{ matrix.variant }} (${{ matrix.arch }})
needs: choose-runners
strategy:
fail-fast: false
matrix:
include:
- variant: gpu
arch: ${{ needs.choose-runners.outputs.gpu_arch }}
- variant: cpu
arch: ${{ needs.choose-runners.outputs.cpu_arch }}
runs-on: ${{ matrix.arch == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set Tags
id: tags
run: |
KEY=${{ matrix.variant }}
ARCH=${{ matrix.arch }}
TAG_ARCH=$(echo "$ARCH" | cut -d'/' -f2)
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
TAG_SHA=$(echo $GITHUB_SHA | cut -c 1-8)
TAG_PR=$GITHUB_EVENT_NAME
else
TAG_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c 1-8)
TAG_PR="PR-${{ github.event.pull_request.number }}"
fi
echo "arch=${ARCH}" >> $GITHUB_OUTPUT
echo "tag_latest=latest-${TAG_ARCH}-${KEY}" >> $GITHUB_OUTPUT
echo "tag_sha=${TAG_SHA}-${TAG_ARCH}-${KEY}" >> $GITHUB_OUTPUT
echo "tag_pr=${TAG_PR}-${TAG_ARCH}-${KEY}" >> $GITHUB_OUTPUT
- name: Free Disk Space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Configure AWS Dev credentials
uses: aws-actions/configure-aws-credentials@v5
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCT_DEV }}:role/${{ env.GHA_ROLE }}
- name: Login to Dev ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Setup BuildX Builder
id: buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Build and push (${{ matrix.variant }})
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: ./Dockerfile-${{ matrix.variant }}
pull: true
push: true
sbom: false
provenance: false
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ env.REPOSITORY }}:${{ steps.tags.outputs.tag_latest }}
${{ steps.login-ecr.outputs.registry }}/${{ env.REPOSITORY }}:${{ steps.tags.outputs.tag_sha }}
${{ steps.login-ecr.outputs.registry }}/${{ env.REPOSITORY }}:${{ steps.tags.outputs.tag_pr }}