Update readme.md #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main # Triggers only on the 'main' branch | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout the repository | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Log in to GitHub Container Registry (GHCR) | |
| - name: Log in to GitHub Container Registry | |
| run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| # Build the Docker image | |
| - name: Build Docker Image | |
| run: | | |
| docker build -t ghcr.io/${{ github.repository_owner }}/flask-webserver:latest . | |
| docker tag ghcr.io/${{ github.repository_owner }}/flask-webserver:latest ghcr.io/${{ github.repository_owner }}/flask-webserver:${{ github.sha }} | |
| # Push the Docker image to GitHub Container Registry | |
| - name: Push Docker Image | |
| run: | | |
| docker push ghcr.io/${{ github.repository_owner }}/flask-webserver:latest | |
| docker push ghcr.io/${{ github.repository_owner }}/flask-webserver:${{ github.sha }} |