Improve git package according to Sam comments

Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau
2021-09-02 14:23:57 +02:00
committed by Guillaume de Rouville
parent 4ad2c8e7e5
commit 95040d8320
4 changed files with 72 additions and 63 deletions

View File

@@ -5,7 +5,7 @@ import (
"alpha.dagger.io/os"
)
// Commit & push to github repository
// Commit & push to git repository
#Commit: {
// Git repository
repository: {
@@ -15,8 +15,8 @@ import (
// Repository remote URL
remote: dagger.#Input & {string}
// Github PAT
PAT: dagger.#Input & {*null | dagger.#Secret}
// Authentication token (PAT or password)
authToken: dagger.#Input & {*null | dagger.#Secret}
// Git branch
branch: dagger.#Input & {string}
@@ -37,7 +37,7 @@ import (
// Force push options
force: dagger.#Input & {*false | bool}
ctr: os.#Container & {
_ctr: os.#Container & {
image: #Image
command: #"""
# Move changes into repository
@@ -69,20 +69,20 @@ import (
}
}
if repository.PAT != null {
env: GIT_ASKPASS: "/get_gitPAT"
files: "/get_gitPAT": {
content: "cat /secret/github_pat"
if repository.authToken != null {
env: GIT_ASKPASS: "/get_authToken"
files: "/get_authToken": {
content: "cat /secrets/authToken"
mode: 0o500
}
secret: "/secret/github_pat": repository.PAT
secret: "/secrets/authToken": repository.authToken
}
}
// Commit hash
hash: {
os.#File & {
from: ctr
from: _ctr
path: "/commit.txt"
}
}.contents & dagger.#Output