diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..b18843a --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,34 @@ +name: Build and Push Docker Image + +on: + push: + paths: + - version.txt # Trigger workflow only when version.txt changes + +jobs: + build: + runs-on: ubuntu-latest + environment: Dockerhub # Use the Dockerhub environment + + steps: + # Step 1: Check out the repository + - name: Checkout code + uses: actions/checkout@v3 + + # Step 2: Log in to Docker Hub + - name: Log in to Docker Hub + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + + # Step 3: Build the Docker image + - name: Build Docker Image + run: | + docker build -t nomadics/alaskarfin:latest . + + # Step 4: Push the Docker image to Docker Hub + - name: Push Docker Image + run: | + docker push nomadics/alaskarfin:latest +