name: Build and Push Docker Image on: push: branches: - main # Runs when code is pushed to the main branch workflow_dispatch: # Allows manual trigger from GitHub UI jobs: build: runs-on: ubuntu-latest # Uses the latest Ubuntu runner steps: # ✅ Step 1: Checkout the repository code - name: Checkout code uses: actions/checkout@v4 # ✅ Step 2: Login to Docker Hub using secrets - name: Login to Docker Hub run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin # ✅ Step 3: Login to GitHub Container Registry (GHCR) using Personal Access Token # Required for pushing to organization-owned namespace (zamibd) - name: Login to GHCR run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin # ✅ Step 4: Build Docker image and tag for both Docker Hub and GHCR - name: Build Docker image run: | docker build . --file Dockerfile \ --tag imzami/socks5:latest \ --tag ghcr.io/zamibd/socks5:latest # ✅ Step 5: Push image to Docker Hub - name: Push to Docker Hub run: docker push imzami/socks5:latest # ✅ Step 6: Push image to GitHub Container Registry (GHCR) - name: Push to GHCR run: docker push ghcr.io/zamibd/socks5:latest