-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.rb
33 lines (26 loc) · 878 Bytes
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true
# Load if it is NOT executed via GitHub Actions
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
unless ENV['CI']
require 'pry'
require 'dotenv'
Dotenv.load
end
require 'json'
require 'yaml'
require_relative 'lib/error'
require_relative 'lib/validator'
require_relative 'lib/article'
require_relative 'lib/qiita'
include Validator
Validator.env
ENV['ADDED_FILES']&.split&.each do |path|
article = Article.new(path: path)
qiita = Qiita.new(content: article.content, header: YAML.safe_load(article.header), mode: 'create', path: path)
qiita.publish
end
ENV['MODIFIED_FILES']&.split&.each do |path|
article = Article.new(path: path)
qiita = Qiita.new(content: article.content, header: YAML.safe_load(article.header), mode: 'update', path: path)
qiita.publish
end