name: Publish docker images
on:
  workflow_dispatch:
jobs:
  docker-publish:
    name: Docker publish
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Node.js v20
        uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Install dependencies
        uses: ./packages/actions/src/pnpmCache

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Login to DockerHub
        run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

      - name: Build & push docker image
        run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push .
