-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathverif_mirror.yml
103 lines (89 loc) · 3.06 KB
/
verif_mirror.yml
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
# Created by @Miou-zora (please keep it ;) )
name: mirror
on:
push:
branches-ignore:
- 'ga-ignore-**'
pull_request:
branches-ignore:
- 'ga-ignore-**'
env:
MIRROR_URL: "MIRROR_URL_MIRROR_GENERATOR"
EXECUTABLES: "EXECUTABLE_MIRROR_GENERATOR"
jobs:
check_repository_cleanliness:
name: Checks if the repository is clean and void of any unwanted files (temp files, binary files, etc.)
runs-on: ubuntu-latest
env:
UNWANTED_REGEX: ^(?!.*tests\/).*gc(no|da|ov)$|(.*\.(a|o|so))$|(.*~)$|^(#.*#)$|(.*(?i)pain_au_chocolat.*)|^tmp\/.*|.*\/tmp\/.*
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Find temp files in all directories
run: |
UNWANTED_FILES=$(find . -type f -printf '%P\n' | { grep -P "${{ env.UNWANTED_REGEX }}" || true; })
if [ "$UNWANTED_FILES" != "" ]; then
IFS=$'\n'$'\r'
for LINE in $UNWANTED_FILES; do
echo "::error file=${LINE},line=1,col=1,title=Unwanted file detected::${LINE}"
done
echo "FAIL_TASK=true" >> "$GITHUB_ENV"
else
echo "FAIL_TASK=false" >> "$GITHUB_ENV"
fi
- name: Fail if needed
if: env.FAIL_TASK == 'true'
run: exit 1
check_program_compilation:
name: Checks if the program compiles correctly and executables files got created
runs-on: ubuntu-latest
needs: [check_repository_cleanliness]
container: epitechcontent/epitest-docker:latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- run: make
timeout-minutes: 2
- run: make clean
- name: Verifies that files are present and executable
run: |
echo "FAIL_TASK=false" >> "$GITHUB_ENV"
SEARCH_BINARIES="${{ env.EXECUTABLES }}"
IFS=$','
for BIN in $SEARCH_BINARIES; do
if [ ! -f "${BIN}" ]; then
echo "::error file=${BIN},title=Binary not found::${BIN}"
echo "FAIL_TASK=true" >> "$GITHUB_ENV"
fi
if [ ! -x "${BIN}" ]; then
echo "::error file=${BIN},title=Binary not executable::${BIN}"
echo "FAIL_TASK=true" >> "$GITHUB_ENV"
fi
done
- name: Fail if needed
if: env.FAIL_TASK == 'true'
run: exit 1
- name: Starts tests
run: make tests_run
timeout-minutes: 2
push_to_mirror:
name: Pushes the current repository files to a given mirror repository
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
needs: [check_program_compilation]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Push mirror repository
uses: pixta-dev/repository-mirroring-action@v1
with:
target_repo_url:
${{ env.MIRROR_URL }}
ssh_private_key:
${{ secrets.GIT_SSH_PRIVATE_KEY }}