Skip to content

Feature/container function test #12

Feature/container function test

Feature/container function test #12

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.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: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to container registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
context: .
platforms: linux/amd64, linux/arm64
tags: oitc/modbus-client:${{steps.application-version.outputs.tag}},oitc/modbus-client:latest