This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
gitlab_satis [2018/08/16 09:06] – admin | gitlab_satis [2018/11/09 14:05] – [Using Environment variable] admin | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Using Gitlab and Satis to generate private composer Repository ====== | ||
+ | [[https:// | ||
+ | |||
+ | **Idea** | ||
+ | |||
+ | * < | ||
+ | * < | ||
+ | * < | ||
+ | * < | ||
+ | * FIXME Run pipeline only if it is not already running, pile up all requests and run it only once. | ||
+ | |||
+ | **Features** | ||
+ | |||
+ | * Write .htaccess according to config.yml (only if '' | ||
+ | * '' | ||
+ | * Order to read configuration: | ||
+ | * '' | ||
+ | * '' | ||
+ | * Use '' | ||
+ | |||
+ | ===== Gitlab CI ===== | ||
+ | |||
+ | The image [[https:// | ||
+ | |||
+ | <code yaml .gitlab-ci.yml> | ||
+ | stages: | ||
+ | - deploy | ||
+ | |||
+ | pages: | ||
+ | stage: deploy | ||
+ | image: ochorocho/ | ||
+ | script: | ||
+ | - mkdir satis-build | ||
+ | - gitlab-pages-satis | ||
+ | - mv satis-build public | ||
+ | artifacts: | ||
+ | paths: | ||
+ | - public/ | ||
+ | only: | ||
+ | - master | ||
+ | </ | ||
+ | |||
+ | ===== Configuration ===== | ||
+ | |||
+ | Go to User Settings -> Access Tokens, give it a name and allow api scope. Hit " | ||
+ | ==== Using Environment variable ==== | ||
+ | |||
+ | In Gitlab go to Project -> Settings -> CI / CD -> Variables and create variable named '' | ||
+ | |||
+ | {{:: | ||
+ | |||
+ | === Using Config File === | ||
+ | |||
+ | Add a config file to your repository. By default the script is looking for '' | ||
+ | |||
+ | <code yaml config.yml> | ||
+ | arguments: | ||
+ | gitlab-url: " | ||
+ | gitlab-token: | ||
+ | options: | ||
+ | ignore: " | ||
+ | homepage: " | ||
+ | output: " | ||
+ | include-if-has-file: | ||
+ | template: '/ | ||
+ | archive: true | ||
+ | basic-auth: | ||
+ | auth-name: "Satis Repository" | ||
+ | auth-file: "/ | ||
+ | username: " | ||
+ | password: " | ||
+ | build-dir: " | ||
+ | </ | ||
+ | |||
+ | Make sure Gitlab Pages is activated for your project. | ||
+ | |||
+ | Trigger the Pipeline, that's it! | ||
+ | |||
+ | ==== Optional ==== | ||
+ | |||
+ | === Satis example template === | ||
+ | |||
+ | Use this template and set configuration (options -> template) if you want to modify ... | ||
+ | |||
+ | * the Twig template | ||
+ | * to use http instead of https | ||
+ | * and all other options that are not covered by [[https:// | ||
+ | |||
+ | <code javascript satis-template.json> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Trigger on tag_push === | ||
+ | |||
+ | Want to trigger your satis projects pipeline each time a Tag is created/ | ||
+ | |||
+ | * Add the follwing file to ''/ | ||
+ | * Make it executable ('' | ||
+ | * validate your plugins using '' | ||
+ | |||
+ | |||
+ | <code ruby gitlab_pages_satis.rb> | ||
+ | # | ||
+ | |||
+ | require ' | ||
+ | require ' | ||
+ | |||
+ | payload = JSON.parse(STDIN.read) | ||
+ | |||
+ | # Only run this code in case we are dealing with tag_push event | ||
+ | if payload[' | ||
+ | |||
+ | temp = Dir.tmpdir() | ||
+ | shaFile = "# | ||
+ | |||
+ | # Get hash values to compare | ||
+ | payloadHash = "# | ||
+ | payloadHashBefore = File.read(shaFile) if File.exist? | ||
+ | |||
+ | # Save before and after hash to compare | ||
+ | File.delete(shaFile) if File.exist? | ||
+ | File.write(shaFile, | ||
+ | |||
+ | # Trigger Pipeline | ||
+ | if payloadHashBefore != payloadHash | ||
+ | | ||
+ | end | ||
+ | end | ||
+ | </ |