Skip to content

Tzwitter - docker initcontainer-import-kernel #16

Tzwitter - docker initcontainer-import-kernel

Tzwitter - docker initcontainer-import-kernel #16

name: Tzwitter - docker initcontainer-import-kernel
on:
push:
branches:
- "infra-main"
paths:
- "./infra_tooling/build_artifacts/09_tzwitter_app/.latest"
workflow_dispatch:
inputs:
rollup_data_dir_name:
description: 'Name of the tzwitter compiled kernel directory to deploy on K8S (eg, tzwitter-834c132-tz1e9eADqkLKnR9h77sAVtZwjRifSJbukFxZ)'
required: true
env:
ARTEFACTS_PROJECT_PATH: ./infra_tooling/build_artifacts/09_tzwitter_app
IMG_SUFFIX: tzwitter
PROJECT_NAME: 09_tzwitter_app
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set image tag vars
id: tag_vars
run: |
echo "date=$(date +%Y-%m-%dT%H-%M-%S)" >> "${GITHUB_OUTPUT}"
echo "sha_short=$(git rev-parse --short HEAD)" >> "${GITHUB_OUTPUT}"
- name: Set rollup_data_dir_name
id: vars_pt1
run: |
if [[ -z "${{ github.event.inputs.rollup_data_dir_name }}" ]]; then
echo "rollup_data_dir_name=$(cat ${{ env.ARTEFACTS_PROJECT_PATH }}/.latest)" >> "${GITHUB_OUTPUT}"
else
echo "rollup_data_dir_name=${{ github.event.inputs.rollup_data_dir_name }}" >> "${GITHUB_OUTPUT}"
fi
- name: Set rollup_data_dir_fullpath
id: vars_pt2
run: |
echo "rollup_data_dir_fullpath=${{ env.ARTEFACTS_PROJECT_PATH }}/${{ steps.vars_pt1.outputs.rollup_data_dir_name }}" >> "${GITHUB_OUTPUT}"
- name: Check rollup_data_dir_fullpath
id: check_rollup_data_dir_fullpath
run: |
echo "rollup_data_dir_fullpath=${{ steps.vars_pt2.outputs.rollup_data_dir_fullpath }}"
if [ ! -d "${{ steps.vars_pt2.outputs.rollup_data_dir_fullpath }}" ]; then
echo "Directory ${{ steps.vars_pt2.outputs.rollup_data_dir_fullpath }} does not exist. Exiting..."
exit 1
fi
- name: Copy Dockerfile and scripts
id: copy
run: |
cp -r ./infra_tooling/docker/initcontainer_import_kernel/* ${{ steps.vars_pt2.outputs.rollup_data_dir_fullpath }}
- 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
id: docker_build
uses: docker/build-push-action@v3
with:
context: ${{ steps.vars_pt2.outputs.rollup_data_dir_fullpath }}
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ github.ref == 'refs/heads/infra-main' }}
tags: |
ghcr.io/marigold-dev/tzwitter-initcontainer-import:${{ steps.vars_pt1.outputs.rollup_data_dir_name }}
ghcr.io/marigold-dev/tzwitter-initcontainer-import:latest
ghcr.io/marigold-dev/tzwitter-initcontainer-import:${{ steps.tag_vars.outputs.date }}-${{ steps.tag_vars.outputs.sha_short }}