Skip to content

Workflow file for this run

name: Build and Publish Docker Image
on:
push:
branches:
- main
release:
types: [ published ]
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Build Docker image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/instagramtomealie:latest .
- name: Tag Docker image
run: |
if [ "${{ github.event_name }}" = "release" ]; then
TAG=${{ github.event.release.tag_name }}
else
TAG="latest"
fi
docker tag ${{ secrets.DOCKER_USERNAME }}/instagramtomealie:latest ${{ secrets.DOCKER_USERNAME }}/instagramtomealie:${TAG}
- name: Push Docker image
run: |
if [ "${{ github.event_name }}" = "release" ]; then
docker push ${{ secrets.DOCKER_USERNAME }}/instagramtomealie:${{ github.event.release.tag_name }}
fi
docker push ${{ secrets.DOCKER_USERNAME }}/instagramtomealie:latest