Skip to content

Commit

Permalink
Add dummy scripts to test integration in other projects
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeyo committed Jul 19, 2024
1 parent 7f46394 commit 047a592
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Deploy GitHub Pages

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
# fuzzy-guide
scripts to help deployment of symfony projects usually within docker ecosystem
# Fuzzy Guide

This repository provides a Symfony bundle to copy scripts to the project root. It also includes documentation for each script.

## Installation

To install the bundle, add the following to your `composer.json`:

```json
{
"require": {
"houseofagile/fuzzy-guide": "dev-main"
},
"extra": {
"symfony-root-dir": "."
}
}
```

Then run `composer install` or `composer update`.

## Documentation

The documentation for each script can be found on the [GitHub Pages site](https://houseofagile.github.io/fuzzy-guide/).
25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "houseofagile/fuzzy-guide",
"description": "A Symfony bundle to copy usefull scripts to the project root, to help with deployment, typically with docker.",
"type": "library",
"require": {
"composer-plugin-api": "^2.0"
},
"autoload": {
"psr-4": {
"HouseOfAgile\\FuzzyGuide\\": "src/"
}
},
"extra": {
"symfony-root-dir": ".",
"script-target-dir": "scripts"
},
"scripts": {
"post-install-cmd": [
"HouseOfAgile\\FuzzyGuide\\Composer\\ScriptHandler::copyScripts"
],
"post-update-cmd": [
"HouseOfAgile\\FuzzyGuide\\Composer\\ScriptHandler::copyScripts"
]
}
}
9 changes: 9 additions & 0 deletions docs/instance_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# instance_config

This script set proper rights for user in symfony projects

## Usage

```bash
./instance_config.sh
```
9 changes: 9 additions & 0 deletions docs/other_script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Another script

This script prints "This is another script" to the console.

## Usage

```bash
./other_script.sh
```
8 changes: 8 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Fuzzy Guide

Welcome to the Fuzzy Guide documentation.

## Scripts

- [Script 1](docs/script1.md)
- [Script 2](docs/script2.md)
38 changes: 38 additions & 0 deletions src/Composer/ScriptHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace HouseOfAgile\FuzzyGuide\Composer;

use Composer\Script\Event;
use Symfony\Component\Yaml\Yaml;

class ScriptHandler
{
public static function copyScripts(Event $event)
{
$extra = $event->getComposer()->getPackage()->getExtra();
$rootDir = isset($extra['symfony-root-dir']) ? $extra['symfony-root-dir'] : '.';

// Read the configuration from the Symfony config file
$configFile = $rootDir . '/config/packages/fuzzy_guide.yaml';
if (file_exists($configFile)) {
$config = Yaml::parseFile($configFile);
$scriptTargetDir = $config['fuzzy_guide']['script_target_dir'];
} else {
$scriptTargetDir = isset($extra['script-target-dir']) ? $extra['script-target-dir'] : 'scripts';
}

$sourceDir = __DIR__ . '/../../scripts';
$targetDir = $scriptTargetDir;

if (!is_dir($targetDir)) {
mkdir($targetDir, 0755, true);
}

foreach (glob($sourceDir . '/*') as $file) {
$fileName = basename($file);
copy($file, $targetDir . '/' . $fileName);
}

$event->getIO()->write('<info>Scripts copied to ' . $targetDir . '</info>');
}
}
7 changes: 7 additions & 0 deletions src/scripts/instance_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

THIS_USER=`whoami`
sudo chown -R ${THIS_USER}.nginx /app/
sudo chown -R ${THIS_USER}.nginx /app/var /app/public
mkdir -p /app/public/uploads
sudo chmod -R 775 /app/var /app/public /app/translations
2 changes: 2 additions & 0 deletions src/scripts/other_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo "This is another script"

0 comments on commit 047a592

Please sign in to comment.