Skip to content

Merge pull request #21 from shanrahul/uat-7.4-ubuntu-20.04 #4

Merge pull request #21 from shanrahul/uat-7.4-ubuntu-20.04

Merge pull request #21 from shanrahul/uat-7.4-ubuntu-20.04 #4

name: OrangeHRM UAT Image Build Workflow
on:
push:
branches: [ uat-7.4-ubuntu-20.04 ]
schedule:
- cron: '30 0 * * MON' # 0030 in UTC, 0600 in IST
env:
REGISTRY: hub.docker.com
DOCKER_HUB_REPO: "orangehrm/orangehrm-environment-images"
TAG_NAME: "uat-7.4-ubuntu-20.04"
LATEST_TAG_NAME: "uat-7.4-ubuntu-20.04"
UPSTREAM_REPO: "orangehrm/orangehrm-test-environment"
UPSTREAM_BRANCH: "refs/heads/uat-7.4-ubuntu-20.04"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Verify prerequisites
run: |
docker --version
docker-compose --version
composer --version
- name: Install test suite dependencies
run: composer install --ignore-platform-reqs
- name: Build docker image
run: docker build -t ${{ env.DOCKER_HUB_REPO }}:${{ env.TAG_NAME }} docker-image
- name: Spin up the container
run: |
docker-compose up -d
docker ps -a
- name: Run unit test suite
run: |
sleep 10s
php vendor/bin/codecept run unit
- name: Get installed php version
run: echo "VERSION_TAG_NAME=test-php-$(docker exec test_web_rhel php -r 'echo PHP_VERSION;')-ubuntu-20.04" >> $GITHUB_ENV
- name: New image with a version tag & latest tag
run: |
docker tag ${{ env.DOCKER_HUB_REPO }}:${{ env.TAG_NAME }} ${{ env.DOCKER_HUB_REPO }}:${{ env.VERSION_TAG_NAME }}
docker tag ${{ env.DOCKER_HUB_REPO }}:${{ env.TAG_NAME }} ${{ env.DOCKER_HUB_REPO }}:${{ env.LATEST_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 with version tag
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: Deploy changes to the docker hub with latest tag
if: ${{ github.repository == env.UPSTREAM_REPO && github.ref == env.UPSTREAM_BRANCH }}
run: |
docker push ${{ env.DOCKER_HUB_REPO }}:${{ env.LATEST_TAG_NAME }}
echo 'SUCCESS - IMAGE WAS PUBLISHED ${{ env.DOCKER_HUB_REPO }}:${{ env.LATEST_TAG_NAME }}'
- name: Docker hub logout
if: ${{ github.repository == env.UPSTREAM_REPO && github.ref == env.UPSTREAM_BRANCH }}
run: docker logout