Add default value for set env vars #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: deploy | |
on: | |
push: | |
branches: | |
- "main" | |
jobs: | |
generate-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set matrix | |
id: set-matrix | |
run: echo "matrix=$(bash ./bin/generate_matrix.sh)" >> $GITHUB_OUTPUT | |
docker: | |
needs: | |
- generate-matrix | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.8' | |
- name: Install poetry | |
run: curl -sSL https://install.python-poetry.org | python3 - | |
- name: Generate requirements file | |
run: bash ./bin/generate_requirements.sh ${{ matrix.version }} ${{ matrix.adapter }} | |
# snowflake adapter for dbt < 1.1 does not have prebuilt arm64 wheels, and building it | |
# from source is very ardious and time consuming (due to pyarrow), so only build for | |
# amd64 for those versions | |
- name: Set build properties | |
id: properties | |
run: | | |
version=${{ matrix.version }} | |
adapter=${{ matrix.adapter }} | |
if ([ -z ${adapter} ] || [ "${adapter}" = "snowflake" ]) && ([ "${version:0:1}" = "0" ] || [ "${version}" = "1.0" ]); then | |
platform="linux/amd64" | |
else | |
platform="linux/amd64,linux/arm64" | |
fi | |
if [ -z ${adapter} ]; then | |
image_name="dbt-full" | |
requirements_file="requirements.txt" | |
else | |
image_name="dbt-${adapter}" | |
requirements_file="requirements-${adapter}.txt" | |
fi | |
echo "platforms=${platform}" | |
echo "image_name=${image_name}" | |
echo "requirements_file=${requirements_file}" | |
echo "platforms=${platform}" >> $GITHUB_OUTPUT | |
echo "image_name=${image_name}" >> $GITHUB_OUTPUT | |
echo "requirements_file=${requirements_file}" >> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
platforms: ${{ steps.properties.outputs.platforms }} | |
push: true | |
tags: ghcr.io/popsql/${{ steps.properties.outputs.image_name }}:${{ matrix.version }} | |
build-args: | | |
REQUIREMENTS_FILE=${{ steps.properties.outputs.requirements_file }} | |
DBT_VERSION=${{ matrix.version }} |