Build and Push Docker Image #161
This file contains hidden or 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
name: Build and Push Docker Image | |
on: | |
push: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
workflow_dispatch: | |
inputs: | |
push_to_dockerhub: | |
description: 'Push to Docker Hub' | |
required: false | |
default: 'false' | |
type: boolean | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v5 | |
- name: Load configuration | |
run: | | |
echo opensource_COBOL_4J_version="$(jq -r '.opensource_COBOL_4J_version' build-config.json)" >> $GITHUB_ENV | |
echo Open_COBOL_ESQL_4J_version="$(jq -r '.Open_COBOL_ESQL_4J_version' build-config.json)" >> $GITHUB_ENV | |
echo version_string_prefix="$(jq -r '.version_string_prefix' build-config.json)" >> $GITHUB_ENV | |
- name: Build a docker image | |
run: | | |
docker build -t opensourcecobol/opensourcecobol4j:"$version_string_prefix" . \ | |
--build-arg opensource_COBOL_4J_version="$opensource_COBOL_4J_version" \ | |
--build-arg Open_COBOL_ESQL_4J_version="$Open_COBOL_ESQL_4J_version" | |
- name: Copy Docker image | |
run: | | |
docker tag opensourcecobol/opensourcecobol4j:"$version_string_prefix" opensourcecobol/opensourcecobol4j:latest | |
- name: Check the version of installed software | |
run: | | |
docker run --rm opensourcecobol/opensourcecobol4j:latest sh -c "cobj --version | grep 'opensource COBOL 4J $opensource_COBOL_4J_version'" | |
docker run --rm opensourcecobol/opensourcecobol4j:latest sh -c "! cobj --version | grep 'unicode/utf-8 support'" | |
docker run --rm opensourcecobol/opensourcecobol4j:latest sh -c "ocesql --version | grep 'Version $Open_COBOL_ESQL_4J_version'" | |
- name: Login to Docker Hub | |
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && inputs.push_to_dockerhub == true | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Push to Docker Hub | |
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && inputs.push_to_dockerhub == true | |
run: | | |
docker push opensourcecobol/opensourcecobol4j:"$version_string_prefix" | |
docker push opensourcecobol/opensourcecobol4j:latest | |
utf8-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v5 | |
- name: Load configuration | |
run: | | |
echo opensource_COBOL_4J_version="$(jq -r '.opensource_COBOL_4J_version' build-config.json)" >> $GITHUB_ENV | |
echo Open_COBOL_ESQL_4J_version="$(jq -r '.Open_COBOL_ESQL_4J_version' build-config.json)" >> $GITHUB_ENV | |
echo version_string_prefix="$(jq -r '.version_string_prefix' build-config.json)" >> $GITHUB_ENV | |
- name: Build a docker image | |
run: | | |
docker build -t opensourcecobol/opensourcecobol4j:utf8-"$version_string_prefix" . -f utf8.Dockerfile \ | |
--build-arg opensource_COBOL_4J_version="$opensource_COBOL_4J_version" | |
- name: Check the version of installed software | |
run: | | |
docker run --rm opensourcecobol/opensourcecobol4j:utf8-"$version_string_prefix" sh -c "cobj --version | grep 'opensource COBOL 4J $opensource_COBOL_4J_version'" | |
docker run --rm opensourcecobol/opensourcecobol4j:utf8-"$version_string_prefix" sh -c "cobj --version | grep 'unicode/utf-8 support'" | |
- name: Login to Docker Hub | |
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && inputs.push_to_dockerhub == true | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Push to Docker Hub | |
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && inputs.push_to_dockerhub == true | |
run: | | |
docker push opensourcecobol/opensourcecobol4j:utf8-"$version_string_prefix" |