Skip to content

Commit 41009d0

Browse files
committed
Refactor GitHub actions to improve development workflow
1 parent 7f91553 commit 41009d0

File tree

7 files changed

+79
-75
lines changed

7 files changed

+79
-75
lines changed
Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,45 @@
11
# Adapted from https://github.com/stackhpc/azimuth/blob/master/.github/workflows/build-push-artifacts.yaml
22
name: Publish artifacts
3-
# Run the tasks on every push
4-
on: push
5-
jobs:
6-
# Job to run change detection
7-
changes:
8-
name: Check for relevant changes
9-
runs-on: ubuntu-latest
10-
# Required permissions
11-
permissions:
12-
pull-requests: read
13-
# Set job outputs to values from filter step
14-
outputs:
15-
images: ${{ steps.filter.outputs.images }}
16-
chart: ${{ steps.filter.outputs.chart }}
17-
steps:
18-
19-
- name: Check out the repository
20-
uses: actions/checkout@v4
213

22-
- uses: dorny/paths-filter@v2
23-
id: filter
24-
with:
25-
base: ${{ github.ref_name }}
26-
# TODO: Make image filters more granular
27-
filters: |
28-
images:
29-
- 'web-apps/**'
30-
chart:
31-
- 'charts/**'
4+
on:
5+
# Publish artifacts on every push to master and every tag
6+
push:
7+
branches:
8+
- master
9+
tags:
10+
- "*"
11+
# Also allow publication to be done via a workflow call
12+
# In this case, the chart version is returned as an output
13+
workflow_call:
14+
inputs:
15+
ref:
16+
type: string
17+
description: The ref to build.
18+
required: true
19+
outputs:
20+
chart-version:
21+
description: The chart version that was published
22+
value: ${{ jobs.build_push_chart.outputs.chart-version }}
3223

33-
# Job to build container images
24+
jobs:
3425
build_push_images:
3526
name: Build and push images
3627
runs-on: ubuntu-latest
37-
permissions:
38-
contents: read
39-
id-token: write # needed for signing the images with GitHub OIDC Token
40-
packages: write # required for pushing container images
41-
security-events: write # required for pushing SARIF files
42-
needs: changes
43-
# if: ${{ github.ref_type == 'tag' || needs.changes.outputs.images == 'true' }}
4428
strategy:
4529
matrix:
4630
include:
4731
- component: chat
4832
- component: image-analysis
33+
permissions:
34+
contents: read
35+
id-token: write # needed for signing the images with GitHub OIDC Token
36+
packages: write # required for pushing container images
37+
security-events: write # required for pushing SARIF files
4938
steps:
5039
- name: Check out the repository
5140
uses: actions/checkout@v4
41+
with:
42+
ref: ${{ inputs.ref || github.ref }}
5243

5344
- name: Login to GitHub Container Registry
5445
uses: docker/login-action@v3
@@ -57,19 +48,23 @@ jobs:
5748
username: ${{ github.actor }}
5849
password: ${{ secrets.GITHUB_TOKEN }}
5950

51+
- name: Get SemVer version for current commit
52+
id: semver
53+
uses: azimuth-cloud/github-actions/semver@master
54+
6055
- name: Calculate metadata for image
6156
id: image-meta
6257
uses: docker/metadata-action@v5
6358
with:
64-
images: ghcr.io/stackhpc/azimuth-llm-${{ matrix.component }}-ui
59+
images: ghcr.io/azimuth-cloud/azimuth-${{ matrix.component }}
6560
# Produce the branch name or tag and the SHA as tags
6661
tags: |
6762
type=ref,event=branch
6863
type=ref,event=tag
69-
type=sha,prefix=
64+
type=raw,value=${{ steps.semver.outputs.short-sha }}
7065
7166
- name: Build and push image
72-
uses: azimuth-cloud/github-actions/docker-multiarch-build-push@test/docker-build-cache
67+
uses: azimuth-cloud/github-actions/docker-multiarch-build-push@master
7368
with:
7469
cache-key: ${{ matrix.component }}
7570
context: ./web-apps/
@@ -79,17 +74,18 @@ jobs:
7974
tags: ${{ steps.image-meta.outputs.tags }}
8075
labels: ${{ steps.image-meta.outputs.labels }}
8176

82-
# Job to build and publish Helm chart
8377
build_push_chart:
8478
name: Build and push Helm chart
8579
runs-on: ubuntu-latest
86-
# Only build and push the chart if chart files have changed
87-
needs: [changes]
88-
if: ${{ github.ref_type == 'tag' || needs.changes.outputs.chart == 'true' }}
80+
# Only build and push the chart if the images built successfully
81+
needs: [build_push_images]
82+
outputs:
83+
chart-version: ${{ steps.semver.outputs.version }}
8984
steps:
9085
- name: Check out the repository
9186
uses: actions/checkout@v4
9287
with:
88+
ref: ${{ inputs.ref || github.ref }}
9389
# This is important for the semver action to work correctly
9490
# when determining the number of commits since the last tag
9591
fetch-depth: 0
@@ -101,7 +97,6 @@ jobs:
10197
- name: Publish Helm charts
10298
uses: azimuth-cloud/github-actions/helm-publish@master
10399
with:
104-
directory: charts
105100
token: ${{ secrets.GITHUB_TOKEN }}
106101
version: ${{ steps.semver.outputs.version }}
107102
app-version: ${{ steps.semver.outputs.short-sha }}

.github/workflows/test-pr.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
1+
# Based on https://github.com/azimuth-cloud/azimuth/blob/master/.github/workflows/test-pr.yaml
12
name: Test pull request
3+
24
on:
3-
pull_request:
5+
# We use pull_request_target so that dependabot-created workflows can run
6+
pull_request_target:
47
types:
58
- opened
6-
- reopened
7-
- ready_for_review
89
- synchronize
10+
- ready_for_review
11+
- reopened
12+
branches:
13+
- master
14+
15+
# Use the head ref for workflow concurrency, with cancellation
16+
# This should mean that any previous workflows for a PR get cancelled when a new commit is pushed
917
concurrency:
1018
group: ${{ github.workflow }}-${{ github.head_ref }}
1119
cancel-in-progress: true
20+
1221
jobs:
22+
# This job exists so that PRs from outside the main repo are rejected
23+
fail_on_remote:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: PR must be from a branch in the azimuth-cloud/azimuth repo
27+
run: exit ${{ github.event.pull_request.head.repo.full_name == 'azimuth-cloud/azimuth' && '0' || '1' }}
28+
29+
publish_artifacts:
30+
needs: [fail_on_remote]
31+
uses: ./.github/workflows/build-push-artifacts.yaml
32+
with:
33+
ref: ${{ github.event.pull_request.head.sha }}
34+
secrets: inherit
35+
1336
chart_validation:
37+
needs: [publish_artifacts]
1438
runs-on: ubuntu-latest
1539
env:
1640
CLUSTER_NAME: chart-testing

charts/azimuth-chat/Chart.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
apiVersion: v2
22
name: azimuth-llm-chat
3-
description: HuggingFace vision model serving along with a simple web interface.
3+
description: HuggingFace large language model serving along with a simple web interface.
44
maintainers:
55
- name: "Scott Davidson"
66
77

88
type: application
99

10+
# The version and appVersion are updated by the chart build script
1011
version: 0.1.0
11-
12-
appVersion: "0.1.0"
12+
appVersion: master
1313

1414
icon: https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg
1515

1616
annotations:
17-
azimuth.stackhpc.com/label: HuggingFace Image Analysis
17+
azimuth.stackhpc.com/label: HuggingFace LLM
1818

1919
dependencies:
2020
- name: azimuth-llm

charts/azimuth-image-analysis/Chart.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
apiVersion: v2
22
name: azimuth-llm-image-analysis
3-
description: HuggingFace vision model serving along with a simple web interface.
3+
description: HuggingFace vision model serving along with a simple web interface for image analysis.
44
maintainers:
55
- name: "Scott Davidson"
66
77

88
type: application
99

10+
# The version and appVersion are updated by the chart build script
1011
version: 0.1.0
11-
12-
appVersion: "0.1.0"
12+
appVersion: master
1313

1414
icon: https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg
1515

1616
annotations:
17-
azimuth.stackhpc.com/label: HuggingFace Image Analysis
17+
azimuth.stackhpc.com/label: HuggingFace VLM
1818

1919
dependencies:
2020
- name: azimuth-llm

charts/azimuth-llm/Chart.yaml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,11 @@ maintainers:
55
- name: "Scott Davidson"
66
77

8-
# A chart can be either an 'application' or a 'library' chart.
9-
#
10-
# Application charts are a collection of templates that can be packaged into versioned archives
11-
# to be deployed.
12-
#
13-
# Library charts provide useful utilities or functions for the chart developer. They're included as
14-
# a dependency of application charts to inject those utilities and functions into the rendering
15-
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
168
type: application
179

18-
# This is the chart version. This version number should be incremented each time you make changes
19-
# to the chart and its templates, including the app version.
20-
# Versions are expected to follow Semantic Versioning (https://semver.org/)
21-
version: 0.2.0
22-
23-
# This is the version number of the application being deployed. This version number should be
24-
# incremented each time you make changes to the application. Versions are not expected to
25-
# follow Semantic Versioning. They should reflect the version the application is using.
26-
# It is recommended to use it with quotes.
27-
appVersion: "1.16.0"
10+
# The version and appVersion are updated by the chart build script
11+
version: 0.1.0
12+
appVersion: master
2813

2914
icon: https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg
3015

charts/azimuth-llm/templates/ui/deployment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
containers:
2525
- name: {{ .Release.Name }}-ui
2626
{{- with .Values.ui.image }}
27-
image: {{ printf "%s:%s" .repository .version }}
27+
image: {{ printf "%s:%s" .repository (default $.Chart.AppVersion .tag) }}
2828
{{- if .imagePullPolicy }}
2929
imagePullPolicy: {{ .imagePullPolicy }}
3030
{{- end -}}

charts/azimuth-llm/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ ui:
8383
# Container image config
8484
image:
8585
repository: ghcr.io/stackhpc/azimuth-llm-chat-ui
86-
version: ef83288
86+
tag: # Defaults to chart's appVersion
8787
imagePullPolicy:
8888
# The settings to be passed to the frontend web app.
8989
# Format depends on the chosen UI image above. For each of the UIs

0 commit comments

Comments
 (0)