Skip to content

Commit 7fda205

Browse files
ci: add Docker build workflow for PR checks
Co-Authored-By: [email protected] <[email protected]>
1 parent fdfeef7 commit 7fda205

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Docker Build Check
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
docker-build-check:
10+
name: Docker Build Check
11+
runs-on: ubuntu-22.04
12+
permissions:
13+
contents: write # Required for creating commit statuses
14+
pull-requests: read
15+
steps:
16+
# Create initial pending status for build check
17+
- name: Create Pending Build Status
18+
env:
19+
GH_TOKEN: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }}
20+
run: |
21+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
22+
gh api \
23+
--method POST \
24+
-H "Accept: application/vnd.github+json" \
25+
-H "X-GitHub-Api-Version: 2022-11-28" \
26+
repos/${{ github.repository }}/statuses/$HEAD_SHA \
27+
-f state="pending" \
28+
-f description="Building SDM Docker image..." \
29+
-f context="SDM Docker Image Build"
30+
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Set up QEMU for multi-platform builds
35+
uses: docker/setup-qemu-action@v3
36+
37+
- name: Set up Docker Buildx
38+
uses: docker/setup-buildx-action@v3
39+
40+
- name: Build Docker image for multiple platforms
41+
id: docker-build
42+
uses: docker/build-push-action@v5
43+
with:
44+
context: .
45+
platforms: linux/amd64,linux/arm64
46+
push: false
47+
tags: airbyte/source-declarative-manifest:pr-${{ github.event.pull_request.number }}
48+
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=SDM Docker image for PR ${{ github.event.pull_request.number }}
49+
50+
- name: Update Build Status on Success
51+
if: success()
52+
env:
53+
GH_TOKEN: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }}
54+
run: |
55+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
56+
gh api \
57+
--method POST \
58+
-H "Accept: application/vnd.github+json" \
59+
-H "X-GitHub-Api-Version: 2022-11-28" \
60+
repos/${{ github.repository }}/statuses/$HEAD_SHA \
61+
-f state="success" \
62+
-f description="SDM Docker image builds successfully" \
63+
-f context="SDM Docker Image Build"
64+
65+
- name: Update Build Status on Failure
66+
if: failure()
67+
env:
68+
GH_TOKEN: ${{ secrets.GH_PAT_MAINTENANCE_OCTAVIA }}
69+
run: |
70+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
71+
gh api \
72+
--method POST \
73+
-H "Accept: application/vnd.github+json" \
74+
-H "X-GitHub-Api-Version: 2022-11-28" \
75+
repos/${{ github.repository }}/statuses/$HEAD_SHA \
76+
-f state="failure" \
77+
-f description="SDM Docker image is broken" \
78+
-f context="SDM Docker Image Build"

0 commit comments

Comments
 (0)