Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
[FEATURE] RIT PUBLISH REPO (ENCAPSULATE GITHUB & GITLAB) (#163)
Browse files Browse the repository at this point in the history
* merge master

* resolve conflicts

* merge upstream

* formula implementation

* formula files

* formula files bis

* Markdown lint

* PRE COMMIT VALIDATION

* Update README
  • Loading branch information
GuillaumeFalourd authored Sep 1, 2020
1 parent 6d4e23a commit 0966fb6
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 6 deletions.
3 changes: 1 addition & 2 deletions github/publish/repo/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"execution": [
"local",
"docker"
"local"
],
"os": {
"deps": [],
Expand Down
2 changes: 1 addition & 1 deletion gitlab/publish/repo/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"qty": 6
},
"label": "Project Name : ",
"name": "projectname",
"name": "project_name",
"type": "text"
},
{
Expand Down
3 changes: 1 addition & 2 deletions gitlab/publish/repo/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"execution": [
"local",
"docker"
"local"
],
"os": {
"deps": [],
Expand Down
2 changes: 1 addition & 1 deletion gitlab/publish/repo/src/formula/formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ checkProjectName() {

runFormula() {

slug_name=$(cleanName "$PROJECTNAME")
slug_name=$(cleanName "$PROJECT_NAME")
checkProjectName $slug_name

cd $WORKSPACE_PATH
Expand Down
4 changes: 4 additions & 0 deletions publish/help.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"long": "Command to publish contents on any platform",
"short": "Publish command"
}
15 changes: 15 additions & 0 deletions publish/repo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM cimg/base:stable-20.04

USER root

RUN curl -fsSL https://commons-repo.ritchiecli.io/install.sh | bash

RUN mkdir /rit
COPY . /rit
RUN sed -i 's/\r//g' /rit/set_umask.sh
RUN sed -i 's/\r//g' /rit/run.sh
RUN chmod +x /rit/set_umask.sh

WORKDIR /app
ENTRYPOINT ["/rit/set_umask.sh"]
CMD ["/rit/run.sh"]
14 changes: 14 additions & 0 deletions publish/repo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SH
BINARY_NAME=run.sh
BIN_FOLDER=bin

build: bash-build docker

bash-build:
mkdir -p $(BIN_FOLDER)
cp -r src/* $(BIN_FOLDER)
mv $(BIN_FOLDER)/main.sh $(BIN_FOLDER)/$(BINARY_NAME)
chmod +x $(BIN_FOLDER)/$(BINARY_NAME)

docker:
cp Dockerfile set_umask.sh $(BIN_FOLDER)
54 changes: 54 additions & 0 deletions publish/repo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!-- markdownlint-disable-file MD013 -->
<!-- markdownlint-disable-file MD033 -->
<!-- markdownlint-disable-file MD024 -->

# Ritchie Publish Repo Formula

## Command

- Set GITHUB or GITLAB credentials ($ rit set credentials) with USERNAME, TOKEN & EMAIL.

- This formula can currently only be executed locally on MacOs or Linux.

## Command

- Prompt

```bash
rit publish repo
```

- Stdin

```bash
echo '{"provider":"Github","privacy":"true", "project_name":"ritchie-formulas-demo", "workspace_path":"/home/users/dennis/ritchie-formulas-local", "version":"v1.0.0"}' | rit publish repo --stdin
```

## Description

This publish command allows the user to create a Githab or Gitlab Ritchie formulas repository based on a local repository.

It encapsulates the `rit github publish repo` and the `rit gitlab publish repo` formulas.

Therefore, it also generates a release and add it to Ritchie repositories ($ rit add repo).
If the repository already exists, it will commit the new code and generate the new release version informed, before updating Ritchie repositories ($ rit update repo).

The user has to inform 5 different kinds of inputs:

- the provider (Github or Gitlab)

- the repository's privacy

- the repository's name

- the local repository path you wish to publish

- the release version to generate

## Demonstration

- Command execution

<img class="special-img-class" src="/publish/repo/docs/img/Github.png" />

<img class="special-img-class" src="/publish/repo/docs/img/Gitlab.png" />
45 changes: 45 additions & 0 deletions publish/repo/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"dockerImageBuilder": "cimg/base:stable-20.04",
"inputs": [
{
"items": [
"Github",
"Gitlab"
],
"label": "Provider : ",
"name": "provider",
"type": "text"
},
{
"cache": {
"active": true,
"newLabel": "Type new value. ",
"qty": 6
},
"label": "Project Name : ",
"name": "project_name",
"type": "text"
},
{
"default": "true",
"items": [
"true",
"false"
],
"label": "Will it be a private repository? ",
"name": "privacy",
"type": "text"
},
{
"label": "Workspace to publish path: (ex: /home/user/dennis/ritchie-formulas)",
"name": "workspace_path",
"type": "text"
},
{
"default": "v1.0.0",
"label": "Version: (default: v1.0.0)",
"name": "version",
"type": "text"
}
]
}
Binary file added publish/repo/docs/img/Github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added publish/repo/docs/img/Gitlab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions publish/repo/help.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"long": "Publish formula repository on Github or Gitlab using rit github/gitlab publish repo formulas",
"short": "Publish formula repository on Github or Gitlab"
}
18 changes: 18 additions & 0 deletions publish/repo/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"execution": [
"local"
],
"os": {
"deps": [],
"support": [
"mac",
"linux"
]
},
"tags": [
"github",
"gitlab",
"publish",
"repo"
]
}
3 changes: 3 additions & 0 deletions publish/repo/set_umask.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
umask 0011
$1
18 changes: 18 additions & 0 deletions publish/repo/src/formula/formula.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# shellcheck disable=SC2181
# shellcheck disable=SC2086
# shellcheck disable=SC2164

runFormula() {
if [ "Github" == $PROVIDER ]
then
echo "🐙 Github provider selected"
echo '{"privacy":"'$PRIVACY'", "project_name":"'$PROJECT_NAME'", "workspace_path":"'$WORKSPACE_PATH'", "version":"'$VERSION'"}' | rit github publish repo --stdin
elif [ "Gitlab" == $PROVIDER ]
then
echo "🦊 Gitlab provider selected"
echo '{"privacy":"'$PRIVACY'", "project_name":"'$PROJECT_NAME'", "workspace_path":"'$WORKSPACE_PATH'", "version":"'$VERSION'"}' | rit gitlab publish repo --stdin
else
echo "🤖 Unexpected Provider informed. Check it please and try again."
fi
}
6 changes: 6 additions & 0 deletions publish/repo/src/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# shellcheck source=/dev/null
. "$(dirname "$0")"/formula/formula.sh --source-only

runFormula

0 comments on commit 0966fb6

Please sign in to comment.