# Reusable workflow, callable from other repos, to build and possibly push a # container image. The container must contain a file /tag which contains the # desired image tag. on: workflow_call: inputs: image_name: description: Image name, like docker.io/me/my_image required: true type: string push: description: True if the image should be pushed after building required: false default: false type: boolean jobs: build: runs-on: cjyar-24 steps: - name: docker login if: ${{ inputs.push == true }} run: docker login -u cjyar -p "${{ secrets.DOCKER_TOKEN }}" - uses: actions/checkout@v4 - name: build run: docker build -t ${{ inputs.image_name }}:${{ github.run_number }} . - name: push if: ${{ inputs.push == true }} run: | docker create --name run_${{ github.run_number }} ${{ inputs.image_name }}:${{ github.run_number }} docker export -o /tmp/image run_${{ github.run_number }} docker rm run_${{ github.run_number }} tar -x -C /tmp -f /tmp/image tag tag=$(cat /tmp/tag) docker tag ${{ inputs.image_name }}:${{ github.run_number }} ${{ inputs.image_name }}:$tag docker push ${{ inputs.image_name }}:$tag