name: Build & Push Docker Image on: push: branches: [main, master] tags: ['v*'] workflow_dispatch: inputs: api_url: description: 'API URL for frontend build' required: false default: 'http://ut.khoavo.myds.me:8981/api' type: string env: REGISTRY: git.khoavo.myds.me IMAGE: git.khoavo.myds.me/vndangkhoa/kv-tube jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log into Forgejo Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ secrets.FORGEJO_USERNAME }} password: ${{ secrets.FORGEJO_PASSWORD }} - name: Extract metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.IMAGE }} tags: | type=sha,prefix= type=ref,event=branch type=semver,pattern={{version}} type=raw,value=latest,enable=${{ github.ref == 'refs/tags/v*' }} - name: Build and push uses: docker/build-push-action@v5 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64 cache-from: type=gha cache-to: type=gha,mode=max build-args: | NEXT_PUBLIC_API_URL=${{ github.event.inputs.api_url || 'http://ut.khoavo.myds.me:8981/api' }}