Repository navigation
62 lines (52 loc) · 1.83 KB
/
Copy pathtesting_mode.yml
File metadata and controls
62 lines (52 loc) · 1.83 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
# .github/workflows/test_testing_mode.yml
name: Test Testing Mode Workflow
on:
pull_request:
branches: [ '*' ]
push:
branches: [ '*' ]
jobs:
test-testing-mode-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check if TESTING_MODE exists
id: check-exists
run: |
if ! grep -q "const TESTING_MODE = " src/App.jsx; then
echo "Error: TESTING_MODE constant not found"
exit 1
fi
- name: Test TESTING_MODE=true check
id: test-true-check
run: |
echo "const TESTING_MODE = true" > test_file.txt
if ! grep -q "const TESTING_MODE = true" test_file.txt; then
echo "Error: True condition check failed"
exit 1
fi
- name: Test TESTING_MODE=false check
id: test-false-check
run: |
echo "const TESTING_MODE = false" > test_file.txt
if ! grep -q "const TESTING_MODE = false" test_file.txt; then
echo "Error: False condition check failed"
exit 1
fi
- name: Force change if TESTING_MODE=true
if: contains(github.ref, 'prod')
run: |
if grep -q "const TESTING_MODE = true" src/App.jsx; then
sed -i 's/const TESTING_MODE = true/const TESTING_MODE = false/' src/App.jsx
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "fix: Set TESTING_MODE to false for production"
git push || {
echo "Created PR to fix TESTING_MODE"
gh pr create --title "fix: Set TESTING_MODE to false" \
--body "Automatically setting TESTING_MODE to false for production" \
--base prod
}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}