Test: Has the blockage been fixed? #32
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 | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| DOCKER_IMAGE: illyaa/homepage | |
| DOCKER_TAG: latest | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Get short SHA | |
| id: vars | |
| run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Build Docker Image | |
| run: | | |
| docker build -t ${{ env.DOCKER_IMAGE }}:${{ steps.vars.outputs.sha_short }} . | |
| - name: Push Docker Image with SHA tag | |
| run: | | |
| docker push ${{ env.DOCKER_IMAGE }}:${{ steps.vars.outputs.sha_short }} | |
| - name: Tag and Push as latest | |
| run: | | |
| docker tag ${{ env.DOCKER_IMAGE }}:${{ steps.vars.outputs.sha_short }} ${{ env.DOCKER_IMAGE }}:latest | |
| docker push ${{ env.DOCKER_IMAGE }}:latest | |
| - name: Build complete | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| echo "Image pushed to Docker Hub" | |
| echo "Run on server: docker compose pull && docker compose up -d" | |