Merge pull request #48 from pasindu07/php-7.4-ubuntu-20.04 #10
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 DEV Image Build Workflow | |
on: | |
push: | |
branches: [ php-7.4-ubuntu-20.04 ] | |
schedule: | |
- cron: '30 0 * * MON' # 0030 in UTC, 0600 in IST | |
workflow_dispatch: | |
env: | |
REGISTRY: hub.docker.com | |
DOCKER_HUB_REPO: "orangehrm/orangehrm-environment-images" | |
TAG_NAME: "dev-php-7.4-ubuntu-20.04" | |
LATEST_TAG_NAME: "dev-php-latest-ubuntu-20.04" | |
UPSTREAM_REPO: "orangehrm/orangehrm-dev-environment" | |
UPSTREAM_BRANCH: "refs/heads/php-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 | |
- 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=dev-php-$(docker exec dev_web php -r 'echo explode("-", PHP_VERSION)[0];')-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 | |
# - name: Send mail on workflow completion with status | |
# if: always() | |
# uses: dawidd6/action-send-mail@v3 | |
# with: | |
# server_address: ${{secrets.MAIL_SERVER_ADDRESS}} | |
# server_port: ${{secrets.MAIL_SERVER_PORT}} | |
# username: ${{secrets.MAIL_USERNAME}} | |
# password: ${{secrets.MAIL_PASSWORD}} | |
# subject: ${{ github.job }} job of ${{ github.repository }} - Status: ${{ job.status }} | |
# body: ${{ github.job }} job in workflow ${{ github.workflow }} of ${{ github.repository }} - Status: ${{ job.status }} | |
# to: [email protected] | |
# from: [email protected] | |
## secure: true | |
# - name: Send email on version change | |
# if: ${{ env.TAG_NAME != env.VERSION_TAG_NAME }} | |
# uses: dawidd6/action-send-mail@v3 | |
# with: | |
# server_address: ${{secrets.MAIL_SERVER_ADDRESS}} | |
# server_port: ${{secrets.MAIL_SERVER_PORT}} | |
# username: ${{secrets.MAIL_USERNAME}} | |
# password: ${{secrets.MAIL_PASSWORD}} | |
# subject: PHP Version of ${{ github.repository }} Changed | |
# body: Latest Image of ${{ github.repository }} has been replaced with ${{ env.VERSION_TAG_NAME }} | |
# to: [email protected] | |
# from: [email protected] | |
## secure: true |