Skip to content

Commit

Permalink
add docker release (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoop authored Mar 29, 2024
1 parent 83ed0aa commit df21b10
Showing 1 changed file with 115 additions and 0 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# **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: false

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: false

jobs:
version_metadata:
name: Get version metadata
runs-on: ubuntu-latest
outputs:
fully_qualified_tags: ${{ steps.tags.outputs.fully_qualified_tags }}
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Get the tags to publish
id: tags
uses: ./.github/actions/latest-wrangler
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.dry_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 }}

0 comments on commit df21b10

Please sign in to comment.