1+ name : CI and Release
2+
3+ on :
4+ push :
5+ branches : [main, cypress-testing-beta]
6+ pull_request :
7+ branches : [main, cypress-testing-beta]
8+ release :
9+ types : [published] # runs only when a release is published in GitHub UI
10+
11+ jobs :
12+ test :
13+ runs-on : ubuntu-latest
14+
15+ services :
16+ mysql :
17+ image : mysql:8
18+ env :
19+ MYSQL_ROOT_PASSWORD : root
20+ MYSQL_DATABASE : joomla
21+ ports :
22+ - 3306:3306
23+ options : >-
24+ --health-cmd="mysqladmin ping -h localhost -uroot -proot"
25+ --health-interval=10s
26+ --health-timeout=5s
27+ --health-retries=5
28+
29+ joomla :
30+ image : joomla:6.0-php8.3-apache
31+ env :
32+ JOOMLA_DB_HOST : mysql
33+ JOOMLA_DB_USER : root
34+ JOOMLA_DB_PASSWORD : root
35+ JOOMLA_DB_NAME : joomla
36+ ports :
37+ - 8080:80
38+ options : >-
39+ --health-cmd="curl -f http://localhost/installation/index.php || exit 1"
40+ --health-interval=15s
41+ --health-timeout=10s
42+ --health-retries=20
43+
44+ steps :
45+ - uses : actions/checkout@v4
46+
47+ - name : Setup PHP
48+ uses : shivammathur/setup-php@v2
49+ with :
50+ php-version : " 8.3"
51+ extensions : zip, mysqli, pdo_mysql
52+
53+ - name : Setup Node.js
54+ uses : actions/setup-node@v4
55+ with :
56+ node-version : " 20.11.1"
57+
58+ - name : Install Composer dependencies
59+ run : composer install --no-progress --prefer-dist --optimize-autoloader
60+
61+ - name : Install NPM dependencies
62+ run : npm install
63+
64+ - name : Install zip utility
65+ run : sudo apt-get update && sudo apt-get install -y zip
66+
67+ - name : Wait for Joomla installer to be ready
68+ run : |
69+ for i in {1..40}; do
70+ if curl -f http://localhost:8080/installation/index.php > /dev/null 2>&1; then
71+ echo "✅ Joomla installer is ready"
72+ break
73+ fi
74+ echo "⏳ Waiting for Joomla installer..."
75+ sleep 10
76+ done
77+
78+ - name : Set Joomla env
79+ run : |
80+ echo "JOOMLA_BASE_URL=http://localhost:8080" >> $GITHUB_ENV
81+ echo "JOOMLA_ADMIN_USER=admin" >> $GITHUB_ENV
82+ echo "JOOMLA_ADMIN_PASS=admin123423454664@" >> $GITHUB_ENV
83+
84+ - name : Run tests
85+ run : composer test
86+ env :
87+ JOOMLA_BASE_URL : http://localhost:8080
88+ JOOMLA_ADMIN_USER : admin
89+ JOOMLA_ADMIN_PASS : admin123423454664@
90+ DBUS_SESSION_BUS_ADDRESS : /dev/null
91+
92+ - name : Upload screenshots on failure
93+ if : always()
94+ uses : actions/upload-artifact@v4
95+ with :
96+ name : test-screenshots
97+ path : cypress/screenshots
98+
99+ - name : Upload videos on failure
100+ if : always()
101+ uses : actions/upload-artifact@v4
102+ with :
103+ name : test-videos
104+ path : cypress/videos
105+
106+ release :
107+ runs-on : ubuntu-latest
108+ needs : test
109+ if : github.event_name == 'release'
110+
111+ steps :
112+ - uses : actions/checkout@v4
113+ with :
114+ fetch-depth : 0 # fetch full history so branches & tags are available
115+
116+ - name : Switch to main branch properly
117+ run : |
118+ git fetch origin main
119+ git checkout -B main origin/main
120+
121+ - name : Extract version from release tag
122+ id : version
123+ run : echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
124+
125+ - name : Create component zip with version
126+ run : |
127+ mkdir -p cypress/fixtures
128+ cd src/component
129+ zip -r ../../cypress/fixtures/com_cmsmigrator_v${{ steps.version.outputs.version }}.zip .
130+
131+ - name : Verify zip file exists
132+ run : ls -lh cypress/fixtures/
133+
134+ - name : Update XML version
135+ run : |
136+ sed -i "s|<version>.*</version>|<version>${{ steps.version.outputs.version }}</version>|" src/component/cmsmigrator.xml
137+
138+ - name : Commit version update
139+ run : |
140+ git config --local user.email "[email protected] " 141+ git config --local user.name "GitHub Action"
142+ git add src/component/cmsmigrator.xml
143+ git commit -m "Bump version to ${{ steps.version.outputs.version }}" || echo "No changes to commit"
144+ git push origin main
145+
146+ - name : Upload asset to GitHub Release
147+ run : |
148+ gh release upload ${{ github.event.release.tag_name }} cypress/fixtures/com_cmsmigrator_v${{ steps.version.outputs.version }}.zip --clobber
149+ env :
150+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments