Skip to content

.github/workflows/release-docker.yml #7

.github/workflows/release-docker.yml

.github/workflows/release-docker.yml #7

# **what?**
# This workflow will generate a series of docker images for dbt and push them to the github container registry
#
# **why?**
# Docker images for dbt are used in a number of important places throughout the dbt ecosystem.
# This is how we keep those images up-to-date.
#
# **when?**
# This is triggered manually
name: Docker release
permissions:
packages: write
on:
workflow_dispatch:
inputs:
package:
description: The package to release
type: choice
options:
- dbt-core
- dbt-bigquery
- dbt-postgres
- dbt-redshift
- dbt-snowflake
- dbt-spark
required: true
version_number:
description: The version number to release as a SemVer (e.g. 1.0.0b1, without `latest` or `v`)
required: true
test_run:
description: Test Run (don't publish)
type: boolean
default: true
workflow_call:
inputs:
package:
description: The package to release
type: string
required: true
version_number:
description: The version number to release as a SemVer (e.g. 1.0.0b1, without `latest` or `v`)
type: string
required: true
test_run:
description: Test Run (don't publish)
type: boolean
default: true
jobs:
version_metadata:
name: Get version metadata
runs-on: ubuntu-latest
outputs:
fully_qualified_tags: ${{ steps.tags.outputs.fully_qualified_tags }}
steps:
- name: Get the tags to publish
id: tags
# this cannot be relative because this workflow is called from multiple repos
# in addition to a manual trigger
uses: dbt-labs/dbt-release/.github/actions/latest-wrangler@main
with:
package_name: ${{ inputs.package }}
new_version: ${{ inputs.version_number }}
github_token: ${{ secrets.GITHUB_TOKEN }}
setup_image_builder:
name: Set up Docker image builder
runs-on: ubuntu-latest
needs: [version_metadata]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
build_and_push:
name: Build images and push to GHCR
runs-on: ubuntu-latest
needs: [setup_image_builder, version_metadata]
steps:
- name: Get docker build arg
id: build_arg
run: |
BUILD_ARG_NAME=$(echo ${{ inputs.package }} | sed 's/\-/_/g')
BUILD_ARG_VALUE=$(echo ${{ inputs.package }} | sed 's/postgres/core/g')
echo "name=$BUILD_ARG_NAME" >> $GITHUB_OUTPUT
echo "value=$BUILD_ARG_VALUE" >> $GITHUB_OUTPUT
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log publishing configuration
shell: bash
run: |
echo Package: ${{ inputs.package }}
echo Version: ${{ inputs.version_number }}
echo Tags: ${{ needs.version_metadata.outputs.fully_qualified_tags }}
echo Build Arg Name: ${{ steps.build_arg.outputs.name }}
echo Build Arg Value: ${{ steps.build_arg.outputs.value }}
- name: Build and push `${{ inputs.package }}`
if: ${{ !inputs.test_run }}
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile
push: True
target: ${{ inputs.package }}
build-args: ${{ steps.build_arg.outputs.name }}_ref=${{ steps.build_arg.outputs.value }}@v${{ inputs.version_number }}
tags: ${{ needs.version_metadata.outputs.fully_qualified_tags }}