diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index a325cb6..0000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Docker Image CI - -on: [push] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag hlds:$(date +%s) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..4045302 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,33 @@ +name: Build and Publish Docker Image + +on: + push: + branches: + - main # Trigger on pushes to the 'main' branch + workflow_dispatch: # Allow manual triggering of the workflow + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + # Checkout the code + - name: Checkout code + uses: actions/checkout@v3 + + # Log in to Docker Hub using GitHub credentials + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # Build the Docker image + - name: Build Docker Image + run: | + docker build -t ${{ secrets.DOCKER_USERNAME }}/hl-server:latest . + + # Push the Docker image to Docker Hub + - name: Push Docker Image + run: | + docker push ${{ secrets.DOCKER_USERNAME }}/hl-server:latest diff --git a/README.md b/README.md index 56e17b1..ed99206 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![GitHub Actions Docker Image CI](https://github.com/jjsalinas/hlds-server/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/jjsalians/hl-server/actions) +[![GitHub Actions Docker Image CI](https://github.com/jjsalinas/hlds-server/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/jjsalinas/hl-server/actions) ![banner](banner.png)