Skip to content

build & push images #18

build & push images

build & push images #18

Workflow file for this run

name: build & push images
on:
release:
types:
- prereleased
- released
workflow_dispatch:
workflow_call:
outputs:
api_image:
description: "The full API image tag"
value: ${{ jobs.build-api.outputs.image_tag }}
queue_image:
description: "The full Queue image tag"
value: ${{ jobs.build-queue.outputs.image_tag }}
ui_image:
description: "The full UI image tag"
value: ${{ jobs.build-ui.outputs.image_tag }}
jobs:
setup:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get commit hash
id: version
run: echo "VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
build-api:
needs: setup
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.image_tag.outputs.value }}
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set image tag
id: image_tag
run: echo "value=${{ secrets.DO_REGISTRY }}/${{ vars.API_IMAGE }}:${{ needs.setup.outputs.version }}" >> $GITHUB_OUTPUT
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DO_REGISTRY_KEY }}
- name: Log in to DO Container Registry
run: doctl registry login --expiry-seconds 600
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push API image
uses: docker/build-push-action@v5
with:
context: .
file: config/api.Dockerfile
push: true
platforms: linux/amd64
tags: |
${{ steps.image_tag.outputs.value }}
cache-from: type=registry,ref=${{ secrets.DO_REGISTRY }}/${{ vars.API_IMAGE }}:buildcache
cache-to: type=registry,ref=${{ secrets.DO_REGISTRY }}/${{ vars.API_IMAGE }}:buildcache,mode=max
- name: Image digest
run: echo "API image digest $(doctl registry repository digest-list ${{ vars.API_IMAGE }} --format Tag,Digest --no-header | grep ${{ needs.setup.outputs.version }})"
build-queue:
needs: setup
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.image_tag.outputs.value }}
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set image tag
id: image_tag
run: echo "value=${{ secrets.DO_REGISTRY }}/${{ vars.QUEUE_IMAGE }}:${{ needs.setup.outputs.version }}" >> $GITHUB_OUTPUT
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DO_REGISTRY_KEY }}
- name: Log in to DO Container Registry
run: doctl registry login --expiry-seconds 600
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Queue image
uses: docker/build-push-action@v5
with:
context: .
file: config/queue.Dockerfile
push: true
platforms: linux/amd64
tags: |
${{ steps.image_tag.outputs.value }}
cache-from: type=registry,ref=${{ secrets.DO_REGISTRY }}/${{ vars.QUEUE_IMAGE }}:buildcache
cache-to: type=registry,ref=${{ secrets.DO_REGISTRY }}/${{ vars.QUEUE_IMAGE }}:buildcache,mode=max
- name: Image digest
run: echo "Queue image digest $(doctl registry repository digest-list ${{ vars.QUEUE_IMAGE }} --format Tag,Digest --no-header | grep ${{ needs.setup.outputs.version }})"
build-ui:
needs: setup
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.image_tag.outputs.value }}
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set image tag
id: image_tag
run: echo "value=${{ secrets.DO_REGISTRY }}/${{ vars.UI_IMAGE }}:${{ needs.setup.outputs.version }}" >> $GITHUB_OUTPUT
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DO_REGISTRY_KEY }}
- name: Log in to DO Container Registry
run: doctl registry login --expiry-seconds 600
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push UI image
uses: docker/build-push-action@v5
with:
context: .
file: config/ui.Dockerfile
push: true
platforms: linux/amd64
tags: |
${{ steps.image_tag.outputs.value }}
cache-from: type=registry,ref=${{ secrets.DO_REGISTRY }}/${{ vars.UI_IMAGE }}:buildcache
cache-to: type=registry,ref=${{ secrets.DO_REGISTRY }}/${{ vars.UI_IMAGE }}:buildcache,mode=max
- name: Image digest
run: echo "UI image digest $(doctl registry repository digest-list ${{ vars.UI_IMAGE }} --format Tag,Digest --no-header | grep ${{ needs.setup.outputs.version }})"