From 367ae865502ca8c30f73caa94befa55f06432264 Mon Sep 17 00:00:00 2001 From: Serhii Londar Date: Wed, 14 Nov 2018 23:40:17 +0200 Subject: [PATCH] Setup CI --- .../ReadmeGenerator.swift | 10 ++++----- .github/deploy.sh | 22 +++++++++++++++++++ .travis.yml | 11 +++++++--- 3 files changed, 34 insertions(+), 9 deletions(-) rename ReadmeGenerator.swift => .github/ReadmeGenerator.swift (97%) create mode 100644 .github/deploy.sh diff --git a/ReadmeGenerator.swift b/.github/ReadmeGenerator.swift similarity index 97% rename from ReadmeGenerator.swift rename to .github/ReadmeGenerator.swift index c490ee7..89c1e8e 100644 --- a/ReadmeGenerator.swift +++ b/.github/ReadmeGenerator.swift @@ -200,7 +200,7 @@ class ReadmeGenerator { func generateReadme() { print("Start") - guard let applicationsData = try? Data(contentsOf: URL(fileURLWithPath: FilePaths.apps .rawValue)) else { return } + guard let applicationsData = try? Data(contentsOf: URL(fileURLWithPath: FilePaths.applications.rawValue)) else { return } guard let categoriesData = try? Data(contentsOf: URL(fileURLWithPath: FilePaths.categories.rawValue)) else { return } let jsonDecoder = JSONDecoder() guard let applicationsObject = try? jsonDecoder.decode(JSONApplications.self, from: applicationsData) else { return } @@ -284,11 +284,9 @@ extension JSONApplication { } enum FilePaths: String { - case readme = "./README.md" - case newReadme = "./NEWREADME.md" - case apps = "./apps.json" - case applications = "./applications.json" - case categories = "./categories.json" + case readme = "./../README.md" + case applications = "./../applications.json" + case categories = "./../categories.json" } struct Constants { diff --git a/.github/deploy.sh b/.github/deploy.sh new file mode 100644 index 0000000..43b408d --- /dev/null +++ b/.github/deploy.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +if [[ $TRAVIS_BRANCH != 'master' ]] +then + exit +fi + +git checkout master + +git config user.name "serhii-londar" +git config user.email "serhii.londar@gmail.com" + +echo add readme +git add README.md + +echo commit +git commit -m "Generate README" + +echo push +git push --quiet "https://${GITHUB_TOKEN}@github.com/serhii-londar/open-source-mac-os-apps.git" master:master > /dev/null 2>&1 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 1651434..e79a1a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,16 @@ -language: ruby +sudo: required +language: swift +osx_image: xcode10 rvm: - 2.2 before_script: - gem install awesome_bot - gem install danger script: - - awesome_bot README.md -w https://matrix.org/blog/home/ + - awesome_bot applications.json -w https://matrix.org/blog/home/ - danger +after_success: + - swift ./.github/ReadmeGenerator.swift + - ./.github/deploy.sh notifications: - email: false + email: false \ No newline at end of file