git-fit 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/git_fit/cli/install_cli.rb +5 -15
- data/lib/git_fit/install/actions.rb +44 -81
- data/lib/git_fit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7e357e4ed167a5b5cbbb76c2490e5e62ffd4883d6e99dc123d492f83e281e583
|
|
4
|
+
data.tar.gz: 94d1327c355f921a120a290f4f8861f7ff4e04e877a30ab0cbc9b8dab2f76e5a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6626c0c270e88df95cda6c74b815fbe97c5813b687b74e9a9631fe8c98245b935d75c29076b4298261835bb48b8319d30a6f6f4758afc79d77210f86082d8ab4
|
|
7
|
+
data.tar.gz: e83614a173412d03c7db1dddeb497d240f37158f301dd1024851b201686ec1926699b6c493a817b5a73a8aecb510a38d247cb1a3cfbdf9938b022612fdf4e889
|
|
@@ -3,20 +3,10 @@ require "fileutils"
|
|
|
3
3
|
|
|
4
4
|
module GitFit
|
|
5
5
|
class InstallCLI < Thor
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
FileUtils.mkdir_p(File.dirname(restore_path))
|
|
13
|
-
FileUtils.mkdir_p(File.dirname(save_path))
|
|
14
|
-
|
|
15
|
-
File.write(restore_path, GitFit::Install::Actions::RESTORE_ACTION)
|
|
16
|
-
File.write(save_path, GitFit::Install::Actions::SAVE_ACTION)
|
|
17
|
-
|
|
18
|
-
say_status :created, restore_path, :green
|
|
19
|
-
say_status :created, save_path, :green
|
|
20
|
-
end
|
|
6
|
+
desc "actions [family]", "Install GitHub Actions (default: all families)"
|
|
7
|
+
def actions(family = nil)
|
|
8
|
+
paths = GitFit::Install::Actions.install(family)
|
|
9
|
+
paths.each { |p| say_status :created, p, :green }
|
|
10
|
+
end
|
|
21
11
|
end
|
|
22
12
|
end
|
|
@@ -1,90 +1,53 @@
|
|
|
1
|
+
require "erb"
|
|
2
|
+
|
|
1
3
|
module GitFit
|
|
2
4
|
module Install
|
|
3
5
|
module Actions
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
TEMPLATE_DIR = File.expand_path("actions", __dir__)
|
|
7
|
+
|
|
8
|
+
def self.render(name, db_path:)
|
|
9
|
+
path = File.join(TEMPLATE_DIR, "#{name}.yml.erb")
|
|
10
|
+
ERB.new(File.read(path)).result_with_hash(db_path: db_path)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.available_families
|
|
14
|
+
Dir.children(TEMPLATE_DIR)
|
|
15
|
+
.select { |e| File.directory?(File.join(TEMPLATE_DIR, e)) }
|
|
16
|
+
.sort
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.install_family(family)
|
|
20
|
+
dir = File.join(TEMPLATE_DIR, family)
|
|
21
|
+
db_path = ENV["GIT_FIT_DATABASE_PATH"] || "db/fit.sqlite3"
|
|
22
|
+
|
|
23
|
+
Dir.glob("*.yml.erb", base: dir).sort.map do |tpl|
|
|
24
|
+
action_name = tpl.delete_suffix(".yml.erb")
|
|
25
|
+
content = render("#{family}/#{action_name}", db_path: db_path)
|
|
26
|
+
out_path = ".github/actions/#{family}/#{action_name}/action.yml"
|
|
27
|
+
FileUtils.mkdir_p(File.dirname(out_path))
|
|
28
|
+
File.write(out_path, content)
|
|
29
|
+
out_path
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.restore_action(db_path = "db/fit.sqlite3")
|
|
34
|
+
render("db-cache/restore", db_path: db_path)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
RESTORE_ACTION = restore_action
|
|
38
|
+
|
|
39
|
+
def self.save_action(db_path = "db/fit.sqlite3")
|
|
40
|
+
render("db-cache/save", db_path: db_path)
|
|
41
|
+
end
|
|
25
42
|
|
|
26
|
-
|
|
27
|
-
shell: bash
|
|
28
|
-
run: |
|
|
29
|
-
db="${{ inputs.path }}"
|
|
30
|
-
ck="${db}.checksum"
|
|
31
|
-
if [ ! -f "$ck" ]; then
|
|
32
|
-
echo "No checksum file — first run or cache miss, skipping verify"
|
|
33
|
-
exit 0
|
|
34
|
-
fi
|
|
35
|
-
if ! sha256sum --check "$ck" --quiet 2>/dev/null; then
|
|
36
|
-
echo "::warning::Checksum mismatch — $db may be corrupted"
|
|
37
|
-
echo "Removing stale files"
|
|
38
|
-
rm -f "$db" "$ck"
|
|
39
|
-
else
|
|
40
|
-
echo "Checksum OK — $db is intact"
|
|
41
|
-
fi
|
|
42
|
-
RESTORE_ACTION_YAML
|
|
43
|
+
SAVE_ACTION = save_action
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
path:
|
|
49
|
-
required: false
|
|
50
|
-
default: db/fit.sqlite3
|
|
51
|
-
key-prefix:
|
|
52
|
-
required: false
|
|
53
|
-
default: git-fit-db
|
|
54
|
-
outputs:
|
|
55
|
-
saved:
|
|
56
|
-
description: "true if cache was updated, false if unchanged"
|
|
57
|
-
value: ${{ steps.detect.outputs.saved }}
|
|
58
|
-
runs:
|
|
59
|
-
using: composite
|
|
60
|
-
steps:
|
|
61
|
-
- name: Detect changes
|
|
62
|
-
id: detect
|
|
63
|
-
shell: bash
|
|
64
|
-
run: |
|
|
65
|
-
db="${{ inputs.path }}"
|
|
66
|
-
ck="${db}.checksum"
|
|
67
|
-
new_sum=$(sha256sum "$db" 2>/dev/null || echo "")
|
|
68
|
-
if [ -z "$new_sum" ]; then
|
|
69
|
-
echo "saved=false" >> "$GITHUB_OUTPUT"
|
|
70
|
-
exit 0
|
|
71
|
-
fi
|
|
72
|
-
if [ -f "$ck" ] && sha256sum --check "$ck" --quiet 2>/dev/null; then
|
|
73
|
-
echo "DB unchanged — skip save"
|
|
74
|
-
echo "saved=false" >> "$GITHUB_OUTPUT"
|
|
75
|
-
exit 0
|
|
76
|
-
fi
|
|
77
|
-
echo "$new_sum" > "$ck"
|
|
78
|
-
echo "saved=true" >> "$GITHUB_OUTPUT"
|
|
45
|
+
def self.install(family = nil)
|
|
46
|
+
families = family ? [family] : available_families
|
|
47
|
+
families.flat_map { |f| install_family(f) }
|
|
48
|
+
end
|
|
79
49
|
|
|
80
|
-
|
|
81
|
-
if: steps.detect.outputs.saved == 'true'
|
|
82
|
-
with:
|
|
83
|
-
path: |-
|
|
84
|
-
${{ inputs.path }}
|
|
85
|
-
${{ inputs.path }}.checksum
|
|
86
|
-
key: ${{ inputs.key-prefix }}-v1-${{ github.run_id }}
|
|
87
|
-
SAVE_ACTION_YAML
|
|
50
|
+
private_class_method :render, :available_families, :install_family
|
|
88
51
|
end
|
|
89
52
|
end
|
|
90
53
|
end
|
data/lib/git_fit/version.rb
CHANGED