Skip to content

Commit 623e70f

Browse files
committedJul 13, 2024
init migration
1 parent 9793bdf commit 623e70f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+7114
-0
lines changed
 

‎.forgejo/workflows/CD.yml

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Deploy to Hosts
2+
on:
3+
pull_request:
4+
types: [closed]
5+
6+
jobs:
7+
deploy:
8+
if: github.event.pull_request.merged == true
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Fetch all history for git diff
15+
run: git fetch --depth=2
16+
17+
- name: Detect modified folders
18+
id: detect-changes
19+
run: |
20+
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
21+
git fetch --unshallow
22+
fi
23+
folders=$(git diff --name-only HEAD~1 HEAD | cut -d/ -f1 | sort | uniq)
24+
echo "Modified folders: $folders"
25+
echo "::set-output name=folders::$folders"
26+
27+
- name: Deploy to hosts
28+
run: |
29+
IFS=' ' read -r -a folder_array <<< "${{ steps.detect-changes.outputs.folders }}"
30+
for folder in "${folder_array[@]}"; do
31+
case $folder in
32+
arrs)
33+
target_host="arrs.lan"
34+
;;
35+
arm)
36+
target_host="arm.lan"
37+
;;
38+
downloaders)
39+
target_host="downloaders.lan"
40+
;;
41+
AI)
42+
target_host="ai.lan"
43+
;;
44+
authentik)
45+
target_host="auth.lan"
46+
;;
47+
cf)
48+
target_host="cf.lan"
49+
;;
50+
jellyfin)
51+
target_host="jf.lan"
52+
;;
53+
kasm)
54+
target_host="kasm.lan"
55+
;;
56+
netboot)
57+
target_host="netboot.lan"
58+
;;
59+
nexus)
60+
target_host="nexus.lan"
61+
;;
62+
pages)
63+
target_host="pages.lan"
64+
;;
65+
portainer)
66+
target_host="port.lan"
67+
;;
68+
twingate)
69+
target_host="twingate.lan"
70+
;;
71+
whisper)
72+
target_host="whisper.lan"
73+
;;
74+
# Add cases for other folders/hosts
75+
*)
76+
echo "Unknown folder: $folder"
77+
continue
78+
;;
79+
esac
80+
echo "Triggering AWX Job with target host: $target_host and folder: $folder"
81+
curl -X POST -k -H "Content-Type: application/json" \
82+
-H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" \
83+
-d "{\"extra_vars\": {\"target_host\": \"$target_host\", \"folder\": \"$folder\"}}" \
84+
"https://awx.mafyuh.xyz/api/v2/job_templates/13/launch/"
85+
86+
sleep 45 # Delay for 45 seconds before fetching logs
87+
88+
job_id=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/job_templates/13/jobs/?order_by=-id | jq -r '.results[0].id')
89+
logs=$(curl -s -H "Authorization: Bearer ${{ secrets.AWX_API_TOKEN }}" https://awx.mafyuh.xyz/api/v2/jobs/$job_id/stdout/?format=json)
90+
echo "AWX Job Logs for folder: $folder"
91+
echo "Range:"
92+
echo "Start: $(echo "$logs" | jq -r '.range.start')"
93+
echo "End: $(echo "$logs" | jq -r '.range.end')"
94+
echo "Absolute End: $(echo "$logs" | jq -r '.range.absolute_end')"
95+
echo "Content:"
96+
echo "$(echo "$logs" | jq -r '.content')"
97+
done

‎.forgejo/workflows/yamllint.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint on PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
lint:
9+
name: Lint YAML files
10+
runs-on: docker
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Install Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: 14
19+
20+
- name: Install yamllint
21+
run: |
22+
npm install -g yaml-lint
23+
24+
- name: Show yamllint version
25+
run: |
26+
yamllint --version
27+
28+
- name: Lint .yml files
29+
run: |
30+
yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" ./**/*.yml

0 commit comments

Comments
 (0)
Please sign in to comment.