-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* composer update * improve deployment * add encrypted beta .env * add images to docker meta step * update readme * improve tags, remove docker login * fix path for encrypted beta env * exclude deployment dir from Docker image * adjust running artisan command on beta * keep deployment scripts dir inside Docker image * disable showing command in the output * fix FATAL: role "root" does not exist * add make commands for development * move faker to require dependencies * add command for creating user in non production environments * code style fix * add LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE in beta env * move LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE to config * move DEPLOYMENT_PROJECT_VERSION_ARG at the end of Dockerfile * bump ssh action
- Loading branch information
Showing
20 changed files
with
857 additions
and
518 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ public/build/ | |
public/hot | ||
.phpunit.result.cache | ||
.env | ||
environment/prod/deployment/beta |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ jobs: | |
environment: beta | ||
name: Deploy to beta | ||
runs-on: ubuntu-22.04 | ||
env: | ||
REPO_NAME: toby | ||
steps: | ||
- name: set branch name | ||
run: echo "BRANCH_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV | ||
|
@@ -29,6 +31,9 @@ jobs: | |
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/setup-buildx-action@v2 | ||
|
||
|
@@ -39,18 +44,42 @@ jobs: | |
username: ${{ github.actor }} | ||
password: ${{ github.token }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository_owner }}/${{ env.REPO_NAME }} | ||
tags: type=raw,value=beta | ||
context: git | ||
|
||
- name: build and push image | ||
uses: docker/build-push-action@v4 | ||
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 }}/toby:beta | ||
cache-from: type=gha, ref=ghcr.io/${{ github.repository_owner }}/toby-beta-build-cache | ||
cache-to: type=gha, ref=ghcr.io/${{ github.repository_owner }}/toby-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.TOBY_VPS_BETA_APP_PATH }} | ||
rm: true | ||
|
||
- name: run deployment script over ssh | ||
uses: appleboy/[email protected].8 | ||
uses: appleboy/[email protected].10 | ||
with: | ||
timeout: 10s | ||
command_timeout: 10m | ||
|
@@ -61,12 +90,6 @@ jobs: | |
passphrase: ${{ secrets.VPS_OVH_BF7EC892_SSH_PRIVATE_KEY_PASSPHRASE }} | ||
script_stop: true | ||
script: | | ||
cd ${{ secrets.TOBY_VPS_BETA_APP_PATH }} | ||
git config user.name "GitHub Actions Bot" | ||
git config user.email "<>" | ||
git fetch | ||
git checkout --force "${{ env.BRANCH_NAME }}" | ||
git pull | ||
git merge --no-commit --no-ff origin/main | ||
make beta-deploy | ||
docker images --filter dangling=true | grep "ghcr.io/blumilksoftware/toby" | awk '{print $3}'| xargs --no-run-if-empty docker rmi | ||
cd ${{ secrets.TOBY_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 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
/vendor | ||
.env | ||
.env.backup | ||
.env.beta | ||
.phpunit.result.cache | ||
docker-compose.override.yml | ||
Homestead.json | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Toby\Infrastructure\Console\Commands\Users; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Validation\ValidationException; | ||
use Toby\Domain\Enums\Role; | ||
use Toby\Eloquent\Models\User; | ||
use ValueError; | ||
|
||
class CreateUser extends Command | ||
{ | ||
protected $signature = "toby:create-user {email} {--role=administrator}"; | ||
protected $description = "Create user in non-production environment."; | ||
|
||
public function handle(): void | ||
{ | ||
if (app()->isProduction()) { | ||
$this->error("User cannot be created in production environment."); | ||
return; | ||
} | ||
|
||
$email = $this->argument("email"); | ||
|
||
try { | ||
Validator::validate(data: ["email" => $email], rules: ["email" => ["email"]]); | ||
} catch (ValidationException) { | ||
$this->error("Invalid email."); | ||
return; | ||
} | ||
|
||
try { | ||
$role = Role::from($this->option("role")); | ||
} catch (ValueError) { | ||
$this->error("Invalid role."); | ||
return; | ||
} | ||
|
||
$userExists = User::query()->where("email", $email)->exists(); | ||
if ($userExists) { | ||
$this->error("Email already exists."); | ||
return; | ||
} | ||
|
||
User::factory([ | ||
"email" => $email, | ||
"role" => $role, | ||
])->create(); | ||
|
||
$this->info("User has been created."); | ||
} | ||
} |
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
Oops, something went wrong.