ci: add Docker build workflow for PR checks #2
Workflow file for this run
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: Docker Build Check | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
docker-build-check: | |
name: Docker Build Check | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: write # Required for creating commit statuses | |
pull-requests: read | |
steps: | |
# Create initial pending status for build check | |
- name: Create Pending Build Status | |
env: | |
GH_TOKEN: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }} | |
run: | | |
HEAD_SHA="${{ github.event.pull_request.head.sha }}" | |
gh api \ | |
--method POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
repos/${{ github.repository }}/statuses/$HEAD_SHA \ | |
-f state="pending" \ | |
-f description="Building SDM Docker image..." \ | |
-f context="SDM Docker Image Build" | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: "poetry" | |
- name: Set up Poetry | |
uses: Gr1N/setup-poetry@v9 | |
with: | |
poetry-version: "2.0.1" | |
# Build the Python package to create the wheel files needed for the Docker build | |
- name: Build Python Package | |
uses: hynek/build-and-inspect-python-package@v2 | |
env: | |
POETRY_DYNAMIC_VERSIONING_BYPASS: "0.0.0dev0" | |
# Copy the wheel files to the dist directory | |
- name: Copy wheel files to dist directory | |
run: | | |
mkdir -p dist | |
cp /tmp/baipp/dist/*.whl dist/ | |
- name: Set up QEMU for multi-platform builds | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image for multiple platforms | |
id: docker-build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: false | |
tags: airbyte/source-declarative-manifest:pr-${{ github.event.pull_request.number }} | |
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=SDM Docker image for PR ${{ github.event.pull_request.number }} | |
- name: Update Build Status on Success | |
if: success() | |
env: | |
GH_TOKEN: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }} | |
run: | | |
HEAD_SHA="${{ github.event.pull_request.head.sha }}" | |
gh api \ | |
--method POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
repos/${{ github.repository }}/statuses/$HEAD_SHA \ | |
-f state="success" \ | |
-f description="SDM Docker image builds successfully" \ | |
-f context="SDM Docker Image Build" | |
- name: Update Build Status on Failure | |
if: failure() | |
env: | |
GH_TOKEN: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }} | |
run: | | |
HEAD_SHA="${{ github.event.pull_request.head.sha }}" | |
gh api \ | |
--method POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
repos/${{ github.repository }}/statuses/$HEAD_SHA \ | |
-f state="failure" \ | |
-f description="SDM Docker image is broken" \ | |
-f context="SDM Docker Image Build" |