Skip to content

Commit ccdb358

Browse files
committed
Fix CI on different branches?
1 parent 226a79c commit ccdb358

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,22 @@ jobs:
5555
path: hacklab-training
5656
fetch-depth: 0
5757

58+
- name: Check if this branch has its own docker image
59+
id: check_image
60+
run: |
61+
IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
62+
if docker pull $IMAGE_NAME; then
63+
echo "Image exists"
64+
echo "exists=true" >> $GITHUB_OUTPUT
65+
else
66+
echo "Image does not exist"
67+
echo "exists=false" >> $GITHUB_OUTPUT
68+
exit 1
69+
fi
70+
5871
- name: Build
5972
run: |
60-
docker run --rm -v $(pwd)/hacklab-training:/material -v $(pwd)/out:/out ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} /material /out
73+
docker run --rm -v $(pwd)/hacklab-training:/material -v $(pwd)/out:/out ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.check_image.exists == 'true' && github.ref_name || 'main' }} /material /out
6174
sudo find out -type f -not -iname '*.pdf' -not -iname '*.html' -delete
6275
6376
- name: Upload artifact

0 commit comments

Comments
 (0)