Merge pull request #18 from deefernando6/mariadb-10.11.5-ubuntu-22.04 #27
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
name: OrangeHRM Database Image Build Workflow | |
on: | |
push: | |
branches: [ mariadb-10.11.5-ubuntu-22.04 ] | |
pull_request: | |
branches: [ mariadb-10.11.5-ubuntu-22.04 ] | |
env: | |
REGISTRY: hub.docker.com | |
DOCKER_HUB_REPO: "orangehrm/orangehrm-db-images" | |
TAG_NAME: "mariadb-10.11.5-ubuntu-22.04" | |
MYSQL_PASSWORD: "1234" | |
UPSTREAM_REPO: "orangehrm/orangehrm-db-images" | |
UPSTREAM_BRANCH: "refs/heads/mariadb-10.11.5-ubuntu-22.04" | |
jobs: | |
Build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Verify prerequisits | |
run: | | |
docker --version | |
docker-compose --version | |
composer --version | |
- name: Install test suite dependencis | |
run: composer install | |
- name: Build docker image | |
run: docker build -t ${{ env.DOCKER_HUB_REPO }}:${{ env.TAG_NAME }} docker-image | |
- name: Spin up a container | |
run: | | |
docker run -itd --name db_container -e MARIADB_ROOT_PASSWORD=${{ env.MYSQL_PASSWORD }} ${{ env.DOCKER_HUB_REPO }}:${{ env.TAG_NAME }} | |
docker ps -a | |
- name: Run unit test suite | |
run: | | |
sleep 10s | |
php vendor/bin/codecept run unit | |
- name: Get installed mariadb version | |
run: echo "VERSION_TAG_NAME=mariadb-$(docker exec db_container mysql -uroot -p1234 --execute='SELECT @@version;' | grep MariaDB | cut -d'-' -f 1)-ubuntu-20.04" >> $GITHUB_ENV | |
- name: New image with a version tag | |
if: ${{ env.TAG_NAME != env.VERSION_TAG_NAME }} | |
run: docker tag ${{ env.DOCKER_HUB_REPO }}:${{ env.TAG_NAME }} ${{ env.DOCKER_HUB_REPO }}:${{ env.VERSION_TAG_NAME }} | |
- name: Docker hub login | |
if: ${{ github.repository == env.UPSTREAM_REPO && github.ref == env.UPSTREAM_BRANCH }} | |
run: docker login -u=${{ secrets.DOCKER_HUB_USERNAME }} -p=${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Deploy changes to the docker hub | |
if: ${{ github.repository == env.UPSTREAM_REPO && github.ref == env.UPSTREAM_BRANCH }} | |
run: | | |
docker push ${{ env.DOCKER_HUB_REPO }}:${{ env.VERSION_TAG_NAME }} | |
echo 'SUCCESS - IMAGE WAS PUBLISHED ${{ env.DOCKER_HUB_REPO }}:${{ env.VERSION_TAG_NAME }}' | |
- name: Docker hub logout | |
if: ${{ github.repository == env.UPSTREAM_REPO && github.ref == env.UPSTREAM_BRANCH }} | |
run: docker logout | |