Skip to content

Test: Has the blockage been fixed? #32

Test: Has the blockage been fixed?

Test: Has the blockage been fixed? #32

Workflow file for this run

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"