Skip to content

fix build docker image with github actions #54

fix build docker image with github actions

fix build docker image with github actions #54

name: Build and Push Docker Image
on:
push:
branches: [master, develop, fix/github-actions]
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Get branch name
id: branch_name
run: echo "::set-output name=BRANCH_NAME::$GITHUB_REF##*/"
- name: Generate tag
id: generate_tag
run: |
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
TAG="${{ secrets.DOCKERHUB_USERNAME }}aiogram-shop-bot-develop"
else
TAG="${{ secrets.DOCKERHUB_USERNAME }}aiogram-shop-bot"
fi
echo "::set-output name=TAG::$TAG"
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.generate_tag.outputs.TAG }}:latest