Skip to content

Commit 5fd0902

Browse files
authored
Restructure container build and push (#6)
1 parent c508f91 commit 5fd0902

File tree

4 files changed

+56
-73
lines changed

4 files changed

+56
-73
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: build-and-push-container-image
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
jobs:
7+
build-and-push-container-image:
8+
name: Build and push container image
9+
runs-on: ubuntu-latest
10+
if: |
11+
github.event_name == 'pull_request' &&
12+
github.event.pull_request.merged == true &&
13+
github.base_ref == inputs.on_base_ref &&
14+
github.event.action == 'closed' &&
15+
(
16+
contains(github.event.pull_request.labels.*.name, 'major') ||
17+
contains(github.event.pull_request.labels.*.name, 'minor') ||
18+
contains(github.event.pull_request.labels.*.name, 'patch')
19+
) &&
20+
!contains(github.event.pull_request.labels.*.name, 'chore')
21+
steps:
22+
- name: Checkout GIT repository
23+
uses: actions/checkout@v3
24+
- name: Get the application version
25+
id: application-version
26+
run: |
27+
image_version=$(grep "^LABEL site.local.program.version=" Dockerfile | cut -d= -f2 | sed -e 's/"//g')
28+
if [ -z "${image_version}" ]; then
29+
echo "ERROR: unable to detect version number!" >&2
30+
exit 1
31+
fi
32+
echo "tag=${image_version}" >> $GITHUB_OUTPUT
33+
- name: Build container image
34+
run: docker build . --file Dockerfile --tag oitc/modbus-server:${{steps.application-version.outputs.tag}}
35+
- name: Login to container registry
36+
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
37+
- name: Push container image to container registry
38+
run: docker push oitc/modbus-server:${{steps.application-version.outputs.tag}}

.github/workflows/build-container-image.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: container-image-build-validation
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- edited
7+
- synchronize
8+
- reopened
9+
jobs:
10+
container-build:
11+
name: Build
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout GIT repository
15+
uses: actions/checkout@v3
16+
- name: Build container image
17+
run: |
18+
docker build . --file Dockerfile --tag container-build:test

.github/workflows/upload-container-image.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)