diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 000000000..b8e24346f --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,45 @@ +name: Build and Publish Docker Image + +on: + push: + branches: [main] + release: + types: [published] + +jobs: + docker-build-publish: + name: Build and Publish Docker Image + runs-on: ubuntu-latest + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Checkout Repository + uses: actions/checkout@v6 + + - name: Log in to Docker Hub + if: github.repository == 'finos/git-proxy' + uses: docker/login-action@v3 + with: + username: finos + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Set Docker Image Tag + id: tags + run: | + if [ "${{ github.event_name }}" = "release" ]; then + echo "tags=finos/git-proxy:${{ github.ref_name }},finos/git-proxy:latest" >> $GITHUB_OUTPUT + else + echo "tags=finos/git-proxy:main" >> $GITHUB_OUTPUT + fi + + - name: Build and Publish Docker Image + if: github.repository == 'finos/git-proxy' + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile + push: true + tags: ${{ steps.tags.outputs.tags }} + provenance: true