Build docker in GH actions #39
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
on: | |
push: | |
branches: | |
- main | |
- release/* | |
jobs: | |
npm_test_build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2-beta | |
with: | |
node-version: "12" | |
check-latest: true | |
# - name: Cache node modules | |
# uses: actions/cache@v4 | |
# id: cache | |
# env: | |
# cache-name: cache-node-modules | |
# with: | |
# path: node_modules | |
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
# restore-keys: | | |
# ${{ runner.os }}-build-${{ env.cache-name }}- | |
# ${{ runner.os }}-build- | |
# ${{ runner.os }}- | |
- name: Install NPM dependencies | |
run: npm ci | |
# - name: Run tests | |
# run: npm test | |
- name: Test NPM compilation | |
run: npm run prod | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: npm_artifact | |
path: public | |
php_test_build: | |
runs-on: ubuntu-latest | |
container: | |
image: kirschbaumdevelopment/laravel-test-runner:7.4 | |
env: | |
DB_CONNECTION: sqlite | |
DB_DATABASE: database/database.sqlite | |
DB_PASSWORD: your_mysql_root_password | |
DB_HOST: mysql | |
DB_USERNAME: root | |
QUEUE_CONNECTION: database | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v1 | |
with: | |
fetch-depth: 1 | |
# - name: Cache PHP dependencies | |
# uses: actions/cache@v4 | |
# id: vendor-cache | |
# with: | |
# path: vendor | |
# key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} | |
- name: Install composer dependencies | |
run: | | |
composer install --no-scripts | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: php_artifact | |
path: vendor | |
- name: Prepare Laravel Application | |
run: | | |
rm -rf bootstrap/cache/* | |
cp .env.example .env | |
cp db.env.example db.env | |
rm -rf database/database.sqlite | |
touch database/database.sqlite | |
php artisan config:clear | |
php artisan cache:clear | |
php artisan route:clear | |
php artisan view:clear | |
php artisan key:generate | |
php artisan config:cache | |
php artisan route:cache | |
- name: Prepare Database | |
run: | | |
php artisan migrate | |
php artisan db:seed | |
php artisan migrate:refresh | |
php artisan db:seed | |
- name: Run Testsuite | |
run: | | |
php artisan generate:jwt-keypair | |
vendor/phpunit/phpunit/phpunit tests/ --colors=never --configuration phpunit_gitlab.xml | |
docker-build: | |
runs-on: ubuntu-latest | |
needs: [npm_test_build, php_test_build] | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
with: | |
fetch-depth: 0 | |
- name: Download npn artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: npm_artifact | |
- name: Download php artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: php_artifact | |
- name: Build the Docker image | |
run: docker build . --file Dockerfile --tag biscofil/kairos:$(date +%s) | |
# helm-build: | |
# runs-on: ubuntu-latest | |
# needs: [npm_test_build, php_test_build] | |
# permissions: | |
# contents: write | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v4 | |
# with: | |
# fetch-depth: 0 | |
# - name: Run chart-releaser | |
# uses: helm/chart-releaser-action@v1.7.0 | |
# env: | |
# CR_TOKEN: "${{ secrets.GH_TOKEN }}" |