You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
1.4 KiB

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/tun2proxy:latest \
--tag ghcr.io/zamibd/tun2proxy:latest
# ✅ Step 5: Push image to Docker Hub
- name: Push to Docker Hub
run: docker push imzami/tun2proxy:latest
# ✅ Step 6: Push image to GitHub Container Registry (GHCR)
- name: Push to GHCR
run: docker push ghcr.io/zamibd/tun2proxy:latest