Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into #24-news
Browse files Browse the repository at this point in the history
# Conflicts:
#	routes/web.php
  • Loading branch information
krzysztofrewak committed Aug 12, 2024
2 parents ddb6412 + 0e3e103 commit e7f1c62
Show file tree
Hide file tree
Showing 243 changed files with 12,943 additions and 2,814 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git/
.idea/
vendor/
node_modules/
.env
.env.beta
./environment/prod/deployment/beta/
1 change: 0 additions & 1 deletion .env.ci
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ DB_PORT=5432
DB_DATABASE=keating
DB_USERNAME=keating
DB_PASSWORD=password
DB_ROOT_PASSWORD=example
28 changes: 2 additions & 26 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,18 @@ APP_KEY=base64:sCsJw8z+d/4ymp0OvzSip2h4Vp2hZZhpV2uOxgTqP94=
APP_DEBUG=true
APP_URL=http://keating.blumilk.localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=pgsql
DB_HOST=keating-db-dev
DB_PORT=5432
DB_ROOT_PASSWORD=example
DB_DATABASE=keating
DB_USERNAME=keating
DB_PASSWORD=password
DB_ROOT_PASSWORD=example

BROADCAST_DRIVER=log
CACHE_DRIVER=redis
FILESYSTEM_DISK=local
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
SESSION_LIFETIME=120

REDIS_HOST=keating-redis-dev
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

# DOCKER
DOCKER_APP_HOST_PORT=53851
DOCKER_INSTALL_XDEBUG=true
DOCKER_DATABASE_HOST_PORT=53853
DOCKER_REDIS_HOST_PORT=53852

DOCKER_INSTALL_XDEBUG=true
DOCKER_HOST_USER_ID=1000
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @blumilksoftware/blumilk
* @blumilksoftware/keating
46 changes: 0 additions & 46 deletions .github/dependabot.yml

This file was deleted.

97 changes: 97 additions & 0 deletions .github/workflows/deploy-to-beta-by-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Deploy to beta by push

concurrency:
group: deploy-beta
cancel-in-progress: true

on:
push:
branches:
- main

jobs:

deploy:
environment: beta
name: Deploy to beta
runs-on: ubuntu-22.04
env:
REPO_NAME: keating
steps:
- name: set branch name
run: echo "BRANCH_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV

- name: checkout
uses: actions/[email protected]
with:
fetch-depth: 0
ref: ${{ env.BRANCH_NAME }}

- name: sync with main branch
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git merge --no-commit --no-ff origin/main
- name: set deployment project version
run: echo "DEPLOYMENT_PROJECT_VERSION=$(bash ./environment/prod/deployment/scripts/version.sh --long)" >> $GITHUB_ENV

- name: set up Docker Buildx
uses: docker/[email protected]

- name: login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Docker meta
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository_owner }}/${{ env.REPO_NAME }}
tags: type=raw,value=beta
context: git

- name: build and push image
uses: docker/[email protected]
with:
context: .
file: ./environment/prod/app/Dockerfile
build-args: DEPLOYMENT_PROJECT_VERSION_ARG=${{ env.DEPLOYMENT_PROJECT_VERSION }}
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ghcr.io/${{ github.repository_owner }}/${{ env.REPO_NAME }}:beta
cache-from: type=gha, ref=ghcr.io/${{ github.repository_owner }}/${{ env.REPO_NAME }}-beta-build-cache
cache-to: type=gha, ref=ghcr.io/${{ github.repository_owner }}/${{ env.REPO_NAME }}-beta-build-cache, mode=max

- name: copy files via ssh
uses: appleboy/[email protected]
with:
timeout: 10s
command_timeout: 10m
host: ${{ secrets.VPS_OVH_BF7EC892_HOST }}
port: ${{ secrets.VPS_OVH_BF7EC892_PORT }}
username: ${{ secrets.VPS_OVH_BF7EC892_USERNAME }}
key: ${{ secrets.VPS_OVH_BF7EC892_SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.VPS_OVH_BF7EC892_SSH_PRIVATE_KEY_PASSPHRASE }}
source: "./environment/prod/deployment/beta/*,./environment/prod/deployment/scripts/*"
target: ${{ secrets.KEATING_VPS_BETA_APP_PATH }}
rm: true

- name: run deployment script over ssh
uses: appleboy/[email protected]
with:
timeout: 10s
command_timeout: 10m
host: ${{ secrets.VPS_OVH_BF7EC892_HOST }}
port: ${{ secrets.VPS_OVH_BF7EC892_PORT }}
username: ${{ secrets.VPS_OVH_BF7EC892_USERNAME }}
key: ${{ secrets.VPS_OVH_BF7EC892_SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.VPS_OVH_BF7EC892_SSH_PRIVATE_KEY_PASSPHRASE }}
script_stop: true
script: |
cd ${{ secrets.KEATING_VPS_BETA_APP_PATH }}/environment/prod/deployment/beta
make beta-deploy BETA_ENV_KEY=${{ secrets.BETA_ENV_KEY }}
docker images --filter dangling=true | grep "ghcr.io/blumilksoftware/${{ env.REPO_NAME }}" | awk '{print $3}'| xargs --no-run-if-empty docker rmi
6 changes: 3 additions & 3 deletions .github/workflows/test-and-lint-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.1

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4.0.2
with:
path: node_modules
key: ${{ runner.os }}-npm-dependencies-${{ hashFiles('package.lock') }}
restore-keys: ${{ runner.os }}-npm-dependencies

- name: Set up node
uses: actions/setup-node@v3
uses: actions/setup-node@v4.0.2
with:
node-version: 20

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-and-lint-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ jobs:
- 5432:5432

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4.1.1

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4.0.2
with:
path: vendor
key: ${{ runner.os }}-composer-dependencies-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-dependencies

- name: Setup PHP
uses: shivammathur/setup-php@v2
uses: shivammathur/setup-php@2.30.2
with:
php-version: 8.2
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, intl
Expand Down
19 changes: 11 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
/.idea
/.vscode
.composer
/node_modules
/public/build
/public/hot
/public/storage
/public/js/
/public/css/
/public/js
/public/css
/public/mix-manifest.json
/vendor

.env
.env.backup
.env.beta
.phpunit.result.cache
.php-cs-fixer.cache
.appversion
.vite
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
google-credentials.json
.idea/
.vscode/
.composer
/public/build/
.appversion
supervisord.pid
.vite
30 changes: 29 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,32 @@ queue:
create-test-db:
@docker compose --file ${DOCKER_COMPOSE_FILE} exec ${DOCKER_COMPOSE_DATABASE_CONTAINER} bash -c 'createdb --username=${DATABASE_USERNAME} ${TEST_DATABASE_NAME} &> /dev/null && echo "Created database for tests (${TEST_DATABASE_NAME})." || echo "Database for tests (${TEST_DATABASE_NAME}) exists."'

.PHONY: init check-env-file build run stop restart shell shell-root test fix create-test-db queue
encrypt-beta-env:
@docker compose --file ${DOCKER_COMPOSE_FILE} run \
--rm \
--no-deps \
--volume ${CURRENT_DIR}/environment/prod/deployment/beta:/envs \
--entrypoint "" \
--workdir /application \
--user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" \
${DOCKER_COMPOSE_APP_CONTAINER} \
bash -c "cp /envs/.env.beta /application \
&& php artisan env:encrypt --env beta --key ${BETA_ENV_KEY} \
&& mv .env.beta.encrypted /envs \
&& rm .env.beta"

decrypt-beta-env:
@docker compose --file ${DOCKER_COMPOSE_FILE} run \
--rm \
--no-deps \
--volume ${CURRENT_DIR}/environment/prod/deployment/beta:/envs \
--entrypoint "" \
--workdir /application \
--user "${CURRENT_USER_ID}:${CURRENT_USER_GROUP_ID}" \
${DOCKER_COMPOSE_APP_CONTAINER} \
bash -c "cp /envs/.env.beta.encrypted /application \
&& php artisan env:decrypt --env beta --key ${BETA_ENV_KEY} \
&& mv .env.beta /envs \
&& rm .env.beta.encrypted"

.PHONY: init check-env-file build run stop restart shell shell-root test fix create-test-db queue encrypt-beta-env decrypt-beta-env
35 changes: 35 additions & 0 deletions app/Actions/ActivateSemesterAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace App\Actions;

use App\Models\Semester;
use Exception;
use Illuminate\Database\ConnectionInterface;

class ActivateSemesterAction
{
public function __construct(
protected ConnectionInterface $db,
) {}

/**
* @throws Exception
*/
public function execute(Semester $semester): void
{
try {
$this->db->beginTransaction();

Semester::getActive()?->update(["active" => 0]);
$semester->update(["active" => 1]);

$this->db->commit();
} catch (Exception $exception) {
$this->db->rollBack();

throw $exception;
}
}
}
20 changes: 0 additions & 20 deletions app/Console/Kernel.php

This file was deleted.

Loading

0 comments on commit e7f1c62

Please sign in to comment.