@@ -32,31 +32,37 @@ jobs:
3232 contents : read
3333 packages : write
3434 steps :
35- - name : Check inputs
36- run : |
37- if [ ${{ inputs.image }} == 'dockermanifestimage' ] && [ ${{ inputs.useBuildx }} == true ]; then
38- echo "dockermanifestimage cannot be built with buildx"
39- exit 1
40- fi
35+ - name : Check branch
36+ run : |
37+ if [ '${{ github.ref }}' != 'refs/heads/main' ] && [[ '${{ github.ref }}' != 'refs/heads/release*' ]] && [ ${{ inputs.publish }} == true ]; then
38+ echo "Cannot publish an image if we are not on main or a release branch."
39+ exit 1
40+ fi
41+ - name : Check inputs
42+ run : |
43+ if [ ${{ inputs.image }} == 'dockermanifestimage' ] && [ ${{ inputs.useBuildx }} == true ]; then
44+ echo "dockermanifestimage cannot be built with buildx"
45+ exit 1
46+ fi
4147
42- if [ ${{ inputs.image }} == 'emptyimage' ] && [ ${{ inputs.useBuildx}} != true ]; then
43- echo "emptyimage should be built with buildx"
44- exit 1
45- fi
46- - name : Checkout repository
47- uses : actions/checkout@v4
48- - name : Login to GitHub Container Registry
49- uses : docker/login-action@v3
50- with :
51- registry : ghcr.io
52- username : ${{ github.actor }}
53- password : ${{ secrets.GITHUB_TOKEN }}
54- - name : Set up Docker Buildx
55- if : ${{ inputs.useBuildx }}
56- uses : docker/setup-buildx-action@v3
57- - name : Build dockerfile and push image
58- uses : docker/build-push-action@v6
59- with :
60- push : ${{ inputs.publish }}
61- context : Tests/TestImages/${{ inputs.image }}
62- tags : ghcr.io/apple/containerization/${{ inputs.image }}:${{ inputs.version }}
48+ if [ ${{ inputs.image }} == 'emptyimage' ] && [ ${{ inputs.useBuildx}} != true ]; then
49+ echo "emptyimage should be built with buildx"
50+ exit 1
51+ fi
52+ - name : Checkout repository
53+ uses : actions/checkout@v4
54+ - name : Login to GitHub Container Registry
55+ uses : docker/login-action@v3
56+ with :
57+ registry : ghcr.io
58+ username : ${{ github.actor }}
59+ password : ${{ secrets.GITHUB_TOKEN }}
60+ - name : Set up Docker Buildx
61+ if : ${{ inputs.useBuildx }}
62+ uses : docker/setup-buildx-action@v3
63+ - name : Build dockerfile and push image
64+ uses : docker/build-push-action@v6
65+ with :
66+ push : ${{ inputs.publish }}
67+ context : Tests/TestImages/${{ inputs.image }}
68+ tags : ghcr.io/apple/containerization/${{ inputs.image }}:${{ inputs.version }}
0 commit comments