Skip to content

Test and build Docker image and push to GitHub Container Registry and deploy the new image to the server #136

Test and build Docker image and push to GitHub Container Registry and deploy the new image to the server

Test and build Docker image and push to GitHub Container Registry and deploy the new image to the server #136

Workflow file for this run

name: Test and build Docker image and push to GitHub Container Registry and deploy the new image to the server
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
laravel-tests:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.2'
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.testing', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Install Frontend Dependencies
run: npm ci && npm run build
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Execute tests via Artisan
run: php artisan test
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: laravel-tests
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Docker Setup Buildx
uses: docker/[email protected]
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: true
tags: "ghcr.io/${{ github.repository }}:latest"