Skip to content

Commit b95b023

Browse files
authored
Update on-tag.yml
1 parent 6accb39 commit b95b023

File tree

1 file changed

+3
-46
lines changed

1 file changed

+3
-46
lines changed

.github/workflows/on-tag.yml

+3-46
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,12 @@ jobs:
2121
service:
2222
- frontend
2323
- backend
24-
runs-on: ${{ github.repository_owner == 'github' && 'ubuntu-latest' || 'self-hosted' }}
24+
runs-on: ubuntu-latest
2525
timeout-minutes: 120
2626
name: Build and push to DockerHub
2727
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]
3829
- name: Replace the current swap file
39-
if: ${{ github.repository_owner == 'github' }}
4030
shell: bash
4131
run: |
4232
sudo swapoff /mnt/swapfile
@@ -47,15 +37,13 @@ jobs:
4737
sudo swapon /mnt/swapfile
4838
4939
- name: Show current memory and swap status
50-
if: ${{ github.repository_owner == 'github' }}
5140
shell: bash
5241
run: |
5342
sudo free -h
5443
echo
5544
sudo swapon --show
5645
5746
- name: Mount a tmpfs over /var/lib/docker
58-
if: ${{ github.repository_owner == 'github' }}
5947
shell: bash
6048
run: |
6149
if [ ! -d "/var/lib/docker" ]; then
@@ -66,7 +54,6 @@ jobs:
6654
sudo systemctl restart docker
6755
sudo df -h | grep docker
6856
69-
# Common steps for both environments
7057
- name: Set env variables
7158
run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
7259

@@ -78,25 +65,8 @@ jobs:
7865
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV
7966

8067
- name: Login to Docker
81-
timeout-minutes: 5
8268
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}}"
10070
- name: Checkout project
10171
uses: actions/checkout@v4
10272

@@ -124,12 +94,7 @@ jobs:
12494
${{ runner.os }}-buildx-
12595
12696
- name: Run Docker buildx for ${{ matrix.service }} against tag
127-
timeout-minutes: 60
128-
continue-on-error: true
129-
id: docker_build
13097
run: |
131-
set -e
132-
echo "Starting Docker build for ${{ matrix.service }}"
13398
docker buildx build \
13499
--cache-from "type=local,src=/tmp/.buildx-cache" \
135100
--cache-to "type=local,dest=/tmp/.buildx-cache" \
@@ -140,11 +105,3 @@ jobs:
140105
--build-context backend=./backend \
141106
--output "type=registry" ./${{ matrix.service }}/ \
142107
--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

Comments
 (0)