Skip to content

Commit 50f2674

Browse files
authored
Initial Docker image workflow (#37)
* Initial Docker image workflow * Update version parsing
1 parent 0fb3a5c commit 50f2674

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

.github/workflows/docker_build.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build someengineering/cloud2sql Docker image
2+
on:
3+
push:
4+
tags:
5+
- '*.*.*'
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
workflow_dispatch:
12+
13+
jobs:
14+
split-build:
15+
name: Build split Docker images
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Check out repository
20+
uses: actions/checkout@v3
21+
22+
- name: Set build platforms
23+
id: platform
24+
run: |
25+
GITHUB_REF="${{ github.ref }}"
26+
GITHUB_TAG=${GITHUB_REF##*/}
27+
echo "targets=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
28+
if [ "${{ github.ref_type }}" = tag ]; then
29+
if [[ "$GITHUB_TAG" =~ [0-9]([ab]|rc)[0-9]* ]]; then
30+
echo "latest=false" >> $GITHUB_OUTPUT
31+
else
32+
echo "latest=true" >> $GITHUB_OUTPUT
33+
fi
34+
else
35+
echo "latest=false" >> $GITHUB_OUTPUT
36+
fi
37+
38+
- name: Check short commit SHA and build targets
39+
run: |
40+
echo ${{ steps.platform.outputs.targets }}
41+
echo ${{ steps.platform.outputs.latest }}
42+
43+
- name: Docker metadata
44+
id: metadata
45+
uses: docker/metadata-action@v4
46+
with:
47+
images: |
48+
someengineering/cloud2sql
49+
ghcr.io/someengineering/cloud2sql
50+
flavor: |
51+
latest=${{ steps.platform.outputs.latest }}
52+
tags: |
53+
type=pep440,pattern={{version}}
54+
type=pep440,pattern={{major}}.{{minor}}
55+
type=pep440,pattern={{major}}
56+
type=sha,prefix=
57+
type=edge
58+
labels: |
59+
org.opencontainers.image.title=cloud2sql
60+
org.opencontainers.image.description=Extract your infrastructure data to a SQL database.
61+
org.opencontainers.image.vendor=Some Engineering Inc.
62+
63+
- name: Set up QEMU
64+
id: qemu
65+
uses: docker/setup-qemu-action@v2
66+
with:
67+
platforms: arm64,amd64
68+
69+
- name: Set up Docker Buildx
70+
id: buildx
71+
uses: docker/setup-buildx-action@v2
72+
73+
- name: Log in to Docker Hub
74+
if: github.event_name != 'pull_request'
75+
uses: docker/login-action@v2
76+
with:
77+
username: ${{ secrets.DOCKERHUB_USER }}
78+
password: ${{ secrets.DOCKERHUB_PASS }}
79+
80+
- name: Log in to GitHub Container Registry
81+
if: github.event_name != 'pull_request'
82+
uses: docker/login-action@v2
83+
with:
84+
registry: ghcr.io
85+
username: ${{ github.actor }}
86+
password: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Build and push cloud2sql Docker image
89+
uses: docker/build-push-action@v3
90+
with:
91+
context: .
92+
file: ./Dockerfile
93+
platforms: ${{ steps.platform.outputs.targets }}
94+
push: ${{ github.event_name != 'pull_request' }}
95+
tags: ${{ steps.metadata.outputs.tags }}
96+
labels: ${{ steps.metadata.outputs.labels }}
97+
provenance: false # Temporary workaround for https://github.com/docker/buildx/issues/1533

0 commit comments

Comments
 (0)