This repository was archived by the owner on Jun 20, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
121 lines (107 loc) · 6.18 KB
/
healthchecks_housekeeping.yaml
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: 🐧🧹 HealthChecks 🖳🗑️
on:
#push:
workflow_dispatch:
#schedule:
# - cron: "15 21 * * *" # 09:45 PM Evening UTC --> 3:00 AM Nepal Time
# https://crontab.guru
# https://savvytime.com/converter/utc-to-nepal-kathmandu
env:
USER_AGENT: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0"
jobs:
Validate:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: main
filter: "blob:none" #https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/
- name: Setup Env
run: |
sudo apt update -y
sudo apt install dos2unix -y
pip install ansi2txt --upgrade
- name: Install Addons
run: |
set +e
#action-lint
sudo curl -qfsSL "https://raw.githubusercontent.com/Azathothas/Toolpacks/main/x86_64/actionlint" -o "/usr/local/bin/actionlint" && sudo chmod +xwr "/usr/local/bin/actionlint"
#delta
sudo curl -qfsSL "https://raw.githubusercontent.com/Azathothas/Toolpacks/main/x86_64/delta" -o "/usr/local/bin/delta" && sudo chmod +xwr "/usr/local/bin/delta"
#eget
sudo curl -qfsSL "https://raw.githubusercontent.com/Azathothas/Toolpacks/main/x86_64/eget" -o "/usr/local/bin/eget" && sudo chmod +xwr "/usr/local/bin/eget"
#validtoml
sudo curl -qfsSL "https://raw.githubusercontent.com/Azathothas/Toolpacks/main/x86_64/validtoml" -o "/usr/local/bin/validtoml" && sudo chmod +xwr "/usr/local/bin/validtoml"
#Yq
sudo curl -qfsSL "https://raw.githubusercontent.com/Azathothas/Toolpacks/main/x86_64/yq" -o "/usr/local/bin/yq" && sudo chmod +xwr "/usr/local/bin/yq"
#Yj
sudo curl -qfsSL "https://raw.githubusercontent.com/Azathothas/Toolpacks/main/x86_64/yj" -o "/usr/local/bin/yj" && sudo chmod +xwr "/usr/local/bin/yj"
continue-on-error: true
- name: Dos2Unix Everything
run: |
#Presets
set +x ; set +e
#--------------#
cd "$GITHUB_WORKSPACE/main"
find . -type f ! -path "./.git/*" -exec dos2unix {} \; 2>/dev/null
continue-on-error: true
- name: ActionLint
run: |
#Presets
set +x ; set +e
#--------------#
cd "$GITHUB_WORKSPACE/main"
find ".github/workflows" -type f -name "*ml" -exec actionlint {} \;
continue-on-error: true
- name: Validate TOML
run: |
#Presets
set +x ; set +e
#--------------#
cd "$GITHUB_WORKSPACE/main/data"
## Just list
#find "$GITHUB_WORKSPACE/main/data" -type f -name '*.toml' ! -name '*SAMPLE_SPEC*' -exec yq --input-format "toml" --output-format "yaml" {} 1>/dev/null \;
# List & Delete
find "$GITHUB_WORKSPACE/main/data" -type f -name '*.toml' ! -name '*SAMPLE_SPEC*' -exec sh -c 'yq --input-format "toml" --output-format "yaml" "$1" 1>/dev/null || rm "$1"' _ {} \;
continue-on-error: true
- name: Validate source
run: |
#Presets
set +x ; set +e
#--------------#
cd "$GITHUB_WORKSPACE/main/data"
## Just list
find "$GITHUB_WORKSPACE/main/data" -type f -name '*.toml' ! -name '*SAMPLE_SPEC*' -exec yq --input-format "toml" --output-format "json" {} 2>/dev/null \; | jq -r 'select(.package.source == "") | .package.architecture + " ❯ " + .package.name + " ✗ " + .package.source' | sort -u
echo -e "\n----------------------------\n"
find "$GITHUB_WORKSPACE/main/data" -type f -name '*.toml' ! -name '*SAMPLE_SPEC*' -exec sh -c 'yq --input-format "toml" --output-format "json" "$1" 2>/dev/null | jq -r --arg workspace "$GITHUB_WORKSPACE" '\''select(.package.source == "") | $workspace + "/main/data/" + .package.architecture + "/" + .package.name + ".toml"'\'' ' _ {} \;
#Delete
echo -e "\n----------------------------\n"
find "$GITHUB_WORKSPACE/main/data" -type f -name '*.toml' ! -name '*SAMPLE_SPEC*' -exec sh -c 'yq --input-format "toml" --output-format "json" "$1" 2>/dev/null | jq -r --arg workspace "$GITHUB_WORKSPACE" '\''select(.package.source == "") | $workspace + "/main/data/" + .package.architecture + "/" + .package.name + ".toml"'\'' ' _ {} \; | xargs rm 2>/dev/null
continue-on-error: true
- name: Generate Diff (Delta)
run: |
#Presets
set +x ; set +e
#--------------#
cd "$GITHUB_WORKSPACE/main"
#aarch64_arm64
echo -e "[+] aarch64_arm64\n" > "$GITHUB_WORKSPACE/main/.github/PKGS_DIFF.txt"
delta -s --raw <(curl -qfsSL "https://api.github.com/repos/Azathothas/Toolpacks/contents/aarch64_arm64/" | jq -r '.[].name' | sort -u) <(curl -qfsSL "https://raw.githubusercontent.com/metis-os/hysp-pkgs/main/data/metadata.json" | jq -r '.packages[] | select(.architecture == "aarch64_arm64")' | jq -r '.name' | sort -u) | ansi2txt | grep -iv "/proc" | tee -a "$GITHUB_WORKSPACE/main/.github/PKGS_DIFF.txt"
#x86_64
echo -e "\n\n[+] x86_64\n" >> "$GITHUB_WORKSPACE/main/.github/PKGS_DIFF.txt"
delta -s --raw <(curl -qfsSL "https://api.github.com/repos/Azathothas/Toolpacks/contents/x86_64/" | jq -r '.[].name' | sort -u) <(curl -qfsSL "https://raw.githubusercontent.com/metis-os/hysp-pkgs/main/data/metadata.json" | jq -r '.packages[] | select(.architecture == "x86_64")' | jq -r '.name' | sort -u) | ansi2txt | grep -iv "/proc" | tee -a "$GITHUB_WORKSPACE/main/.github/PKGS_DIFF.txt"
continue-on-error: true
# - name: Git Pull
# run: |
# cd "$GITHUB_WORKSPACE/main" && git pull origin main
# continue-on-error: true
- uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: ./main
commit_user_name: Azathothas # defaults to "github-actions[bot]"
commit_user_email: [email protected] # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
commit_message: "✅ 🐧🧹 Purged Bad TOML 🖳🗑️"
#push_options: '--force'