Skip to content

Commit

Permalink
add automatic container build validation and build and push workflow (#6
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cybcon authored Jan 23, 2023
1 parent dfd1ae9 commit 0afa752
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build-and-push-container-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: build-and-push-container-image
on:
pull_request:
types:
- closed
jobs:
build-and-push-container-image:
name: Build and push container image
runs-on: ubuntu-latest
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
github.base_ref == inputs.on_base_ref &&
github.event.action == 'closed' &&
(
contains(github.event.pull_request.labels.*.name, 'major') ||
contains(github.event.pull_request.labels.*.name, 'minor') ||
contains(github.event.pull_request.labels.*.name, 'patch')
) &&
!contains(github.event.pull_request.labels.*.name, 'chore')
steps:
- name: Checkout GIT repository
uses: actions/checkout@v3
- name: Get the application version
id: application-version
run: |
image_version=$(grep "^LABEL site.local.program.version=" Dockerfile | cut -d= -f2 | sed -e 's/"//g')
if [ -z "${image_version}" ]; then
echo "ERROR: unable to detect version number!" >&2
exit 1
fi
echo "tag=${image_version}" >> $GITHUB_OUTPUT
- name: Build container image
run: docker build . --file Dockerfile --tag oitc/modbus-client:${{steps.application-version.outputs.tag}}
- name: Login to container registry
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Push container image to container registry
run: docker push oitc/modbus-client:${{steps.application-version.outputs.tag}}
18 changes: 18 additions & 0 deletions .github/workflows/container-image-build-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: container-image-build-validation
on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
jobs:
container-build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout GIT repository
uses: actions/checkout@v3
- name: Build container image
run: |
docker build . --file Dockerfile --tag container-build:test

0 comments on commit 0afa752

Please sign in to comment.