Skip to content

SOCAR Airflow 이미지 빌더 #79

SOCAR Airflow 이미지 빌더

SOCAR Airflow 이미지 빌더 #79

name: SOCAR Airflow 이미지 빌더
on:
workflow_dispatch:
inputs:
airflow-version:
description: '에어플로우 버전'
required: true
default: '2.5.3'
python-version:
description: '파이썬 버전'
required: true
default: '3.8'
extra-pip-packages:
description: '추가 pip 패키지'
required: false
default: 'apache-airflow[sentry],datadog,gspread,acryl-datahub-airflow-plugin,xmltodict,apache-airflow-providers-cncf-kubernetes,pytest'
extra-git-repo:
description: '추가 git repo python 패키지'
required: false
image-repository:
description: '이미지 repository 주소'
required: false
default: "gcr.io/socar-data/apache-airflow"
extra-image-tag:
required: false
description: '추가적인 이미지의 태그. 기본값: v<airflow-version>-<python-version>-YYYYMMDD-<extra-image-tag>'
jobs:
build_and_push:
runs-on: ubuntu-latest
name: SOCAR Airflow
steps:
- name: Output Inputs
run: echo "${{ toJSON(github.event.inputs) }}"
- uses: actions/checkout@v3
- name: Set current date as env variable
run: echo "NOW=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Set up target version
run: echo "TARGET_VERSION=v${{ github.event.inputs.airflow-version }}-python${{ github.event.inputs.python-version }}-${{ env.NOW }}-${{ github.event.inputs.extra-image-tag }}" >> $GITHUB_ENV
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'
- name: Login to GCR
uses: docker/login-action@v1
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ github.event.inputs.image-repository }}
tags: |
type=raw,value=${{ env.TARGET_VERSION }}
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SOCAR_DE_PRIVATE_KEY }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
file: Dockerfile.socar
build-args: |
EXTRA_PIP_PACKAGES=${{ github.event.inputs.extra-pip-packages }}
EXTRA_GIT_REPOS=${{ github.event.inputs.extra-git-repo }}
AIRFLOW_BASE_IMAGE=apache/airflow:${{ github.event.inputs.airflow-version }}-python${{ github.event.inputs.python-version }}
ssh: |
socar-de=/home/runner/.ssh/id_rsa
- name: Notify to Channel
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: "dp_monitor_cicd"
SLACK_USERNAME: Airflow Image Builder
SLACK_ICON_EMOJI: ":airflow:"
SLACK_TITLE: Message
SLACK_MESSAGE: '[${{ github.events.inputs.image-repository }}] Airflow Custom Image ${{ env.TARGET_VERSION }}이 배포됐습니다'