name: Build Container run-name: Build Container on: push: jobs: container: name: Build Container runs-on: ubuntu-latest container: docker steps: - name: Build Container run: | git clone -b "${{github.ref_name}}" "$(echo ${{github.server_url}}/${{github.repository}}.git | sed s%://%://${{github.token}}@% )" . VERSION=$(cat Dockerfile | grep "ARG CADDY_VERSION" | grep -Eo '=.+' | grep -Eo '[[:alnum:]\.\/\-]+') PREFIX=$(echo ${{github.server_url}} | sed s%http://%% | sed s%https://%% ) docker build -t $PREFIX/${{ github.repository }}:${{ github.ref_name }} . docker push $PREFIX/${{ github.repository }}:${{ github.ref_name }} docker tag $PREFIX/${{ github.repository }}:$VERSION $PREFIX/${{ github.repository }}:${{ github.ref_name }} docker push $PREFIX/${{ github.repository }}:$VERSION [ '${{ github.ref_name }}' == 'master' ] && \ docker tag $PREFIX/${{ github.repository }}:latest $PREFIX/${{ github.repository }}:${{ github.ref_name }} && \ docker push $PREFIX/${{ github.repository }}:latest || echo '' tag: name: Git Tag runs-on: ubuntu-latest container: alpine/git steps: - name: Git Tag run: | git clone -b "${{github.ref_name}}" "$(echo ${{github.server_url}}/${{github.repository}}.git | sed s%://%://${{github.token}}@% )" . VERSION=$(cat Dockerfile | grep "ARG CADDY_VERSION" | grep -Eo '=.+' | grep -Eo '[[:alnum:]\.\/\-]+') tag -f $VERSION ${{github.sha}} git push -f origin $VERSION