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