diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..c3b367d --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,61 @@ +name: build-push +on: + workflow_call: + inputs: + image: + description: 'Image name' + required: true + type: 'string' + tag: + description: 'Name for docker tag' + required: false + type: 'string' + default: 'latest' + push: + description: 'Push image' + required: false + type: 'boolean' + default: false + context: + description: 'Docker build context path' + required: false + type: 'string' + default: '.' + secrets: + USERNAME: + description: 'Registry username' + required: true + PASSWORD: + description: 'Registry password' + required: true + ORGANIZATION: + description: 'Registry organization' + required: true + +jobs: + build-push: + runs-on: ubuntu-22.04 + + steps: + - name: Clone repository + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + + - name: Log + run: | + echo Building: ${{ inputs.image }}:${{ inputs.tag }} image + + - name: Build and push image + uses: docker/build-push-action@v5 + with: + context: ${{ inputs.context }} + push: ${{ inputs.push }} + tags: ${{ secrets.ORGANIZATION }}/${{ inputs.image }}:${{ inputs.tag }} \ No newline at end of file