diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 23d1494..64ec036 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -5,8 +5,8 @@ name: CI # Controls when the workflow will run on: # Triggers the workflow on push or pull request events but only for the master branch - #push: - # branches: [ automation-template ] + push: + branches: [ automation-template ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: diff --git a/generate-template-json.py b/generate-template-json.py index 321490f..b4776e6 100755 --- a/generate-template-json.py +++ b/generate-template-json.py @@ -16,41 +16,51 @@ result["templates"] = [] templates = [] for filename in glob.glob("*.y*ml"): - data = [] - dataset = {} - repository = {} - env = [] - categories = [] - file = open(filename) - for line in file.readlines(): - if re.search('#&', line): - data=line[3:-1].split(': ', 1) - if data[0] == "categories": - categories = data[1].split(', ') - dataset[data[0]] = categories - else: - dataset[data[0]] = data[1] - if re.search('#%', line): - envtemp = {} - dataenv=line[3:-1].split(': ', 1) - envtemp["name"] = dataenv[0] - envtemp["label"] = dataenv[1] - env.append(envtemp) - if data: - repository = { - "url": GITHUB_REPOSITORY_URL, - "stackfile": filename - } - dataset["repository"] = repository - dataset["env"] = env - templates.append(dataset) - - #else: - #print (f"{filename} not updated !") + try: + data = [] + dataset = {} + repository = {} + env = [] + categories = [] + file = open(filename) + for line in file.readlines(): + if re.search('#&', line): + data=line[3:-1].split(': ', 1) + if data[0] == "type": + type_=int(data[1]) + dataset[data[0]] = type_ + elif data[0] == "categories": + categories = data[1].split(', ') + dataset[data[0]] = categories + else: + dataset[data[0]] = data[1] + if re.search('#%', line): + envtemp = {} + dataenv=line[3:-1].split(': ', 1) + envtemp["name"] = dataenv[0] + envtemp["label"] = dataenv[1] + env.append(envtemp) + if data: + repository = { + "url": GITHUB_REPOSITORY_URL, + "stackfile": filename + } + dataset["repository"] = repository + #dataset["type"] = 3 + dataset["env"] = env + templates.append(dataset) + print (f" ✅ {filename} ") + + else: + print (f" 🚸 {filename} not updated !") + except: + print (f" ❌ {filename} error !") -result["templates"] = templates -json_data = json.dumps(result, indent=4) -with open('templates-portainer.json', 'w') as outfile: - outfile.write(json_data) - -print ("File generated !") \ No newline at end of file +try: + result["templates"] = templates + json_data = json.dumps(result, indent=4) + with open('templates-portainer.json', 'w') as outfile: + outfile.write(json_data) + print ("\n ✅ File generated !") +except: + print (" ❌ Error when generate !") \ No newline at end of file diff --git a/templates-portainer.json b/templates-portainer.json index 78cf082..2d25324 100644 --- a/templates-portainer.json +++ b/templates-portainer.json @@ -35,40 +35,6 @@ } ] }, - { - "type": 3, - "title": "Website HTML PHP 3", - "description": "Simple HTML website under PHP 7.4", - "note": "Website: Github.com", - "categories": [ - "SelfHosted", - "PAPAMICA" - ], - "platform": "linux", - "logo": "http://assets.stickpng.com/thumbs/5847f5bdcef1014c0b5e489c.png", - "repository": { - "url": "https://github.com/PAPAMICA/docker-compose-collection", - "stackfile": "website-html copy 2.yml" - }, - "env": [ - { - "name": "SERVICE", - "label": "name of the service (no spaces or points)" - }, - { - "name": "DATA_LOCATION", - "label": "data localization (example: /apps/service)" - }, - { - "name": "URL", - "label": "service link (example: service.papamica.fr or service.com)" - }, - { - "name": "NETWORK", - "label": "your Traefik network (example: proxy)" - } - ] - }, { "type": 3, "title": "Website HTML PHP 2", @@ -102,6 +68,40 @@ "label": "your Traefik network (example: proxy)" } ] + }, + { + "type": 3, + "title": "Website HTML PHP 3", + "description": "Simple HTML website under PHP 7.4", + "note": "Website: Github.com", + "categories": [ + "SelfHosted", + "PAPAMICA" + ], + "platform": "linux", + "logo": "http://assets.stickpng.com/thumbs/5847f5bdcef1014c0b5e489c.png", + "repository": { + "url": "https://github.com/PAPAMICA/docker-compose-collection", + "stackfile": "website-html copy 2.yml" + }, + "env": [ + { + "name": "SERVICE", + "label": "name of the service (no spaces or points)" + }, + { + "name": "DATA_LOCATION", + "label": "data localization (example: /apps/service)" + }, + { + "name": "URL", + "label": "service link (example: service.papamica.fr or service.com)" + }, + { + "name": "NETWORK", + "label": "your Traefik network (example: proxy)" + } + ] } ] } \ No newline at end of file diff --git a/website-html copy 2.yml b/website-html copy 2.yml index ab622bc..28be493 100644 --- a/website-html copy 2.yml +++ b/website-html copy 2.yml @@ -4,7 +4,7 @@ #& type: 3 #& title: Website HTML PHP 3 #& description: Simple HTML website under PHP 7.4 -# note: Website: Github.com +#& note: Website: Github.com #& categories: SelfHosted, PAPAMICA #& platform: linux #& logo: http://assets.stickpng.com/thumbs/5847f5bdcef1014c0b5e489c.png diff --git a/website-html copy.yml b/website-html copy.yml index eab23e5..3d32a3f 100644 --- a/website-html copy.yml +++ b/website-html copy.yml @@ -4,7 +4,7 @@ #& type: 3 #& title: Website HTML PHP 2 #& description: Simple HTML website under PHP 7.4 -# note: Website: Github.com +#& note: Website: Github.com #& categories: SelfHosted, PAPAMICA #& platform: linux #& logo: http://assets.stickpng.com/thumbs/5847f5bdcef1014c0b5e489c.png diff --git a/website-html.yml b/website-html.yml index f59fda0..223b555 100644 --- a/website-html.yml +++ b/website-html.yml @@ -4,7 +4,7 @@ #& type: 3 #& title: Website HTML PHP #& description: Simple HTML website under PHP 7.4 -# note: Website: Github.com +#& note: Website: Github.com #& categories: SelfHosted, PAPAMICA #& platform: linux #& logo: http://assets.stickpng.com/thumbs/5847f5bdcef1014c0b5e489c.png