Skip to content

Commit c3c26b3

Browse files
committed
feat: add docker_build_test and py_release
1 parent cd5aa6c commit c3c26b3

File tree

3 files changed

+104
-12
lines changed

3 files changed

+104
-12
lines changed

.github/workflows/az_acr_push.yml

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ name: 'ACR: Docker Push'
22

33
on:
44
workflow_call:
5-
5+
inputs:
6+
image_tag:
7+
description: 'Image Tag (semantic version)'
8+
required: false
9+
default: null
10+
type: string
611

712
jobs:
8-
az-acr-push:
13+
az-acr-push-dev:
914
name: "Azure: ACR Build & Push"
1015
runs-on: ubuntu-latest
1116
environment: dev
17+
if: github.event.inputs.image_tag == null
1218
env:
1319
DOCKERFILE: ${{ vars.DOCKERFILE || 'Dockerfile' }}
1420
AZURE_CONTAINER_REGISTRY: ${{ secrets.AZURE_CONTAINER_REGISTRY }}
@@ -39,13 +45,44 @@ jobs:
3945
push: true
4046
build-args: platform=linux/${{ matrix.platform}}
4147

42-
# - name: Build & Push - Replace branch
43-
# if: ${{ github.ref != github.repository.default_branch }}
44-
# uses: docker/build-push-action@v5
45-
# with:
46-
# push: true
47-
# file: ${{ env.DOCKERFILE }}
48-
# tags: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:${{ matrix.platform}}-${{ github.ref_name }}
49-
# cache-from: type=gha
50-
# cache-to: type=gha,mode=max
51-
# build-args: platform=linux/${{ matrix.platform}}
48+
- name: Build & Push - Replace branch
49+
if: ${{ github.ref != github.repository.default_branch }}
50+
uses: docker/build-push-action@v5
51+
with:
52+
push: true
53+
file: ${{ env.DOCKERFILE }}
54+
tags: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:${{ matrix.platform}}-${{ github.ref_name }}
55+
cache-from: type=gha
56+
cache-to: type=gha,mode=max
57+
build-args: platform=linux/${{ matrix.platform}}
58+
59+
60+
az-acr-push-prod:
61+
name: "Azure: ACR Build & Push"
62+
runs-on: ubuntu-latest
63+
environment: prod
64+
if: github.event.inputs.image_tag != null
65+
env:
66+
AZURE_CONTAINER_REGISTRY: ${{ secrets.AZURE_CONTAINER_REGISTRY }}
67+
ACR_LOGIN_USERNAME: ${{ secrets.ACR_LOGIN_USERNAME }}
68+
ACR_LOGIN_PASSWORD: ${{ secrets.ACR_LOGIN_PASSWORD }}
69+
steps:
70+
- name: Checkout repository
71+
uses: actions/checkout@v4
72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v3
74+
- name: Log into registry
75+
uses: docker/login-action@v3
76+
with:
77+
registry: "${{ env.AZURE_CONTAINER_REGISTRY }}"
78+
username: "${{ env.ACR_LOGIN_USERNAME }}"
79+
password: "${{ env.ACR_LOGIN_PASSWORD }}"
80+
81+
- name: Build & Push
82+
uses: docker/build-push-action@v5
83+
with:
84+
push: true
85+
file: Dockerfile
86+
tags: ${{ env.AZURE_CONTAINER_REGISTRY }}/${{ github.event.repository.name }}:${{ github.event.inputs.image_tag }}
87+
build-args: platform=linux/amd64
88+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: 'Docker: Build & Test'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
test_cmd:
7+
description: 'Test Command'
8+
required: false
9+
default: null
10+
type: string
11+
12+
jobs:
13+
docker-build-test:
14+
name: "Docker: Build & Test"
15+
runs-on: ubuntu-latest
16+
if: github.event.inputs.test_cmd != null
17+
env:
18+
DOCKERFILE: 'dev.Dockerfile'
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Build & Test
26+
uses: docker/build-push-action@v5
27+
with:
28+
cache-from: type=gha
29+
cache-to: type=gha,mode=max
30+
file: ${{ env.DOCKERFILE }}
31+
tags: ${{ github.event.repository.name }}:test
32+
33+
- name: Test
34+
run: |
35+
export WORKDIR=$(cat ${{ env.DOCKERFILE }} | grep WORKDIR | awk '{print $2}')
36+
docker run --name ${{ github.event.repository.name }} --rm ${{ github.event.repository.name }}:test
37+
docker exec -it ${{ github.event.repository.name }} sh -c "cd ${WORKDIR} && ${{ github.event.inputs.test_cmd }}"
38+

.github/workflows/py_release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "Python: Release"
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
jobs:
11+
py-release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: googleapis/release-please-action@v4
15+
with:
16+
token: ${{ secrets.TOKEN_GITHUB }}
17+
release-type: python

0 commit comments

Comments
 (0)