-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add automatic container build validation and build and push workflow (#6
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |