@@ -21,26 +21,40 @@ jobs:
21
21
service :
22
22
- frontend
23
23
- backend
24
- # Add fail-fast configuration
24
+ runner-label :
25
+ - ubuntu-latest
26
+ - self-hosted
25
27
fail-fast : false
26
- runs-on : ${{ github.event.repository.has_issues && 'ubuntu-latest' || 'self-hosted' }}
28
+ runs-on : ${{ matrix.runner-label }}
29
+ continue-on-error : ${{ matrix.runner-label == 'self-hosted' }}
27
30
timeout-minutes : 120
28
- name : Build and push to DockerHub
29
- # Add concurrency group to prevent multiple runs
31
+ name : Build ${{ matrix.service }} on ${{ matrix.runner-label }}
30
32
concurrency :
31
- group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.service }}
33
+ group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.service }}-${{ matrix.runner-label }}
32
34
cancel-in-progress : true
35
+
33
36
steps :
34
- # Workaround based on JonasAlfredsson/[email protected]
35
- - name : Replace the current swap file
37
+ - name : Runner check
38
+ id : runner-check
39
+ run : |
40
+ echo "Running on ${{ matrix.runner-label }}"
41
+ if [ "${{ matrix.runner-label }}" = "self-hosted" ]; then
42
+ echo "Using self-hosted runner"
43
+ else
44
+ echo "Using GitHub-hosted runner"
45
+ fi
46
+
47
+ # Skip swap configuration for GitHub-hosted runners
48
+ - name : Configure swap
49
+ if : matrix.runner-label == 'self-hosted'
36
50
shell : bash
37
51
run : |
38
- sudo swapoff /mnt/swapfile
39
- sudo rm -v /mnt/swapfile
40
- sudo fallocate -l 13G /mnt/swapfile
52
+ sudo swapoff /mnt/swapfile || true
53
+ sudo rm -f /mnt/swapfile || true
54
+ sudo fallocate -l 13G /mnt/swapfile || true
41
55
sudo chmod 600 /mnt/swapfile
42
56
sudo mkswap /mnt/swapfile
43
- sudo swapon /mnt/swapfile
57
+ sudo swapon /mnt/swapfile || true
44
58
45
59
- name : Show current memory and swap status
46
60
shell : bash
50
64
sudo swapon --show
51
65
52
66
- name : Mount a tmpfs over /var/lib/docker
67
+ if : matrix.runner-label == 'self-hosted'
53
68
shell : bash
54
69
run : |
55
70
if [ ! -d "/var/lib/docker" ]; then
60
75
sudo systemctl restart docker
61
76
sudo df -h | grep docker
62
77
63
- # Add caching for Cargo registry
64
78
- name : Cache Cargo registry
65
79
uses : actions/cache@v3
66
80
with :
69
83
restore-keys : |
70
84
${{ runner.os }}-cargo-registry-
71
85
72
- # Add caching for Cargo index
73
86
- name : Cache Cargo index
74
87
uses : actions/cache@v3
75
88
with :
78
91
restore-keys : |
79
92
${{ runner.os }}-cargo-index-
80
93
81
- # Add caching for Cargo build
82
94
- name : Cache Cargo build
83
95
uses : actions/cache@v3
84
96
with :
97
109
- name : Add SHORT_SHA env property with commit short sha
98
110
run : echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
99
111
100
- # - name: Login to Docker for building
101
- # run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
102
-
103
112
- name : Login to Docker
104
113
run : |
105
114
docker login -u "sondreb" -p "${{secrets.DOCKER_KEY}}"
0 commit comments