-
Notifications
You must be signed in to change notification settings - Fork 4
103 lines (84 loc) · 4.07 KB
/
build-workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: OrangeHRM UAT Image Build Workflow
on:
push:
branches: [ php-7.4-rhel-8 ]
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: "uat-php-7.4.19-rhel-8"
LATEST_TAG_NAME: "uat-php-latest-rhel-8"
UPSTREAM_REPO: "orangehrm/orangehrm-uat-environment"
UPSTREAM_BRANCH: "refs/heads/php-7.4-rhel-8"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Verify prerequisites
run: |
docker --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 }} --build-arg REDHAT_USERNAME=${{ secrets.REDHAT_USERNAME }} --build-arg REDHAT_PASSWORD=${{ secrets.REDHAT_PASSWORD }} 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=uat-php-$(docker exec uat_web_rhel php -r 'echo PHP_VERSION;')-rhel-8" >> $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: techops@orangehrm.com
# from: noreply@orangehrm.com
## 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: techops@orangehrm.com
# from: noreply@orangehrm.com
## secure: true