Skip to content

Always run artifact publishing on tags #298

Always run artifact publishing on tags

Always run artifact publishing on tags #298

# Adapted from https://github.com/stackhpc/azimuth/blob/master/.github/workflows/build-push-artifacts.yaml
name: Publish artifacts
# Run the tasks on every push
on: push
jobs:
# Job to run change detection
changes:
name: Check for relevant changes
runs-on: ubuntu-latest
if: ${{ github.ref_type != 'tag' }}
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
images: ${{ steps.filter.outputs.images }}
chart: ${{ steps.filter.outputs.chart }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.ref_name }}
# TODO: Make image filters more granular
filters: |
images:
- 'web-apps/**'
chart:
- 'charts/**'
# Job to build container images
build_push_images:
name: Build and push images
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # needed for signing the images with GitHub OIDC Token
packages: write # required for pushing container images
security-events: write # required for pushing SARIF files
needs: changes
if: ${{ github.ref_type == 'tag' || needs.changes.outputs.images == 'true' }}
strategy:
matrix:
include:
- component: chat
- component: image-analysis
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate metadata for image
id: image-meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/stackhpc/azimuth-llm-${{ matrix.component }}-ui
# Produce the branch name or tag and the SHA as tags
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha,prefix=
- name: Build and push image
uses: azimuth-cloud/github-actions/docker-multiarch-build-push@update-trivy-action
with:
cache-key: ${{ matrix.component }}
context: ./web-apps/
file: ./web-apps/${{ matrix.component }}/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.image-meta.outputs.tags }}
labels: ${{ steps.image-meta.outputs.labels }}
# Job to build and publish Helm chart
build_push_chart:
name: Build and push Helm chart
runs-on: ubuntu-latest
# Only build and push the chart if chart files have changed
needs: [changes]
if: ${{ github.ref_type == 'tag' || needs.changes.outputs.chart == 'true' }}
steps:
- name: Check out the repository
uses: actions/checkout@v4
with:
# This is important for the semver action to work correctly
# when determining the number of commits since the last tag
fetch-depth: 0
- name: Get SemVer version for current commit
id: semver
uses: azimuth-cloud/github-actions/semver@master
- name: Publish Helm charts
uses: azimuth-cloud/github-actions/helm-publish@master
with:
directory: charts
token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ steps.semver.outputs.version }}
app-version: ${{ steps.semver.outputs.short-sha }}