-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (58 loc) · 2.23 KB
/
dev.yaml
File metadata and controls
67 lines (58 loc) · 2.23 KB
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
name: Dev Build Artifacts and Deploying
on:
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: self-hosted-non-prod
steps:
# Sanity check
- name: Run
run: |
/usr/bin/docker images
# When self-hosting this is necessary
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
# Parsing files list
- name: List of changed files
id: changed-files
uses: tj-actions/changed-files@v39
- name: String to multiline
id: convert
run: |
echo 'MULTILINE<<EOF' >> $GITHUB_ENV
echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr " " "\n" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
# Applying only changed files
- if: ${{ env.MULTILINE != '' }}
name: Applying
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ $file == */Dockerfile ]]; then
echo "Building: $file"
### Exclusive for Github Actions Runner
if [[ $file == runner/* ]]; then
sed -i "s/<TOKEN>/${{ secrets.TOKEN }}/g;s/<ENV>/dev/g" $file
sed -i "s/<CERT_ONE>/${{ secrets.CERT_ONE }}/g;s/<CERT_TWO>/${{ secrets.CERT_TWO }}/g;s/<RSA_PRIVATE>/${{ secrets.RSA_PRIVATE }}/g" $(dirname "$file")/kube_config
fi
###
### Exclusive for Cloudflare Tunnel
if [[ $file == tunnel/* ]]; then
sed -i "s/<CLOUDFLARE>/${{ secrets.CLOUDFLARE }}/g;s/<ENV>/dev/g" $file
fi
###
/usr/bin/docker build $(dirname "$file") -t 10.10.10.100:32000/$(dirname $(dirname "$file")):dev
echo "Pushing..."
/usr/bin/docker push 10.10.10.100:32000/$(dirname $(dirname "$file")):dev
fi
done
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ $file == *.yaml && $file != .github/workflows/* ]]; then
echo "Deploying: $file"
/usr/local/bin/kubectl apply -f <(sed "s/\${ENV}/dev/g" $file)
fi
done