@@ -21,22 +21,12 @@ jobs:
21
21
service :
22
22
- frontend
23
23
- backend
24
- runs-on : ${{ github.repository_owner == 'github' && ' ubuntu-latest' || 'self-hosted' }}
24
+ runs-on : ubuntu-latest
25
25
timeout-minutes : 120
26
26
name : Build and push to DockerHub
27
27
steps :
28
- - name : Validate runner
29
- run : |
30
- echo "Runner name: ${{ runner.name }}"
31
- echo "Runner OS: ${{ runner.os }}"
32
- if [ -z "${{ runner.name }}" ]; then
33
- echo "Error: Runner not properly initialized"
34
- exit 1
35
- fi
36
-
37
- # Only run these steps on GitHub-hosted runners
28
+ # Workaround based on JonasAlfredsson/[email protected]
38
29
- name : Replace the current swap file
39
- if : ${{ github.repository_owner == 'github' }}
40
30
shell : bash
41
31
run : |
42
32
sudo swapoff /mnt/swapfile
@@ -47,15 +37,13 @@ jobs:
47
37
sudo swapon /mnt/swapfile
48
38
49
39
- name : Show current memory and swap status
50
- if : ${{ github.repository_owner == 'github' }}
51
40
shell : bash
52
41
run : |
53
42
sudo free -h
54
43
echo
55
44
sudo swapon --show
56
45
57
46
- name : Mount a tmpfs over /var/lib/docker
58
- if : ${{ github.repository_owner == 'github' }}
59
47
shell : bash
60
48
run : |
61
49
if [ ! -d "/var/lib/docker" ]; then
66
54
sudo systemctl restart docker
67
55
sudo df -h | grep docker
68
56
69
- # Common steps for both environments
70
57
- name : Set env variables
71
58
run : echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
72
59
78
65
run : echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
79
66
80
67
- name : Login to Docker
81
- timeout-minutes : 5
82
68
run : |
83
- max_attempts=3
84
- attempt=1
85
- while [ $attempt -le $max_attempts ]; do
86
- if docker login -u "sondreb" -p "${{secrets.DOCKER_KEY}}"; then
87
- echo "Docker login successful"
88
- break
89
- else
90
- echo "Docker login attempt $attempt failed"
91
- if [ $attempt -eq $max_attempts ]; then
92
- echo "All Docker login attempts failed"
93
- exit 1
94
- fi
95
- sleep 10
96
- ((attempt++))
97
- fi
98
- done
99
-
69
+ docker login -u "sondreb" -p "${{secrets.DOCKER_KEY}}"
100
70
- name : Checkout project
101
71
uses : actions/checkout@v4
102
72
@@ -124,12 +94,7 @@ jobs:
124
94
${{ runner.os }}-buildx-
125
95
126
96
- name : Run Docker buildx for ${{ matrix.service }} against tag
127
- timeout-minutes : 60
128
- continue-on-error : true
129
- id : docker_build
130
97
run : |
131
- set -e
132
- echo "Starting Docker build for ${{ matrix.service }}"
133
98
docker buildx build \
134
99
--cache-from "type=local,src=/tmp/.buildx-cache" \
135
100
--cache-to "type=local,dest=/tmp/.buildx-cache" \
@@ -140,11 +105,3 @@ jobs:
140
105
--build-context backend=./backend \
141
106
--output "type=registry" ./${{ matrix.service }}/ \
142
107
--build-arg commitHash=$SHORT_SHA
143
-
144
- - name : Handle build failure
145
- if : steps.docker_build.outcome == 'failure'
146
- run : |
147
- echo "Docker build failed for ${{ matrix.service }}"
148
- echo "Cleaning Docker cache"
149
- docker builder prune -f
150
- exit 1
0 commit comments