Update docker-image.yml #6
This file contains 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: Docker Image CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Log in to GitHub Container Registry | |
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin | |
- name: Build the Docker image | |
run: | | |
IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/somochkin-blog | |
TIMESTAMP=$(date +%s) | |
docker build . --file Dockerfile --tag $IMAGE_NAME:$TIMESTAMP | |
docker tag $IMAGE_NAME:$TIMESTAMP $IMAGE_NAME:latest | |
echo $IMAGE_NAME:$TIMESTAMP > image_name.txt | |
- name: Debug output | |
run: cat image_name.txt | |
- name: Push the Docker image | |
run: | | |
IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/somochkin-blog | |
TIMESTAMP=$(cat image_name.txt) | |
echo "Pushing image $IMAGE_NAME:$TIMESTAMP" | |
echo "Pushing image $IMAGE_NAME:latest" | |
docker push $IMAGE_NAME:$TIMESTAMP | |
docker push $IMAGE_NAME:latest |