Skip to content

Build and Push Docker Image #28

Build and Push Docker Image

Build and Push Docker Image #28

Workflow file for this run

name: Build and Push Docker Image
on:
workflow_dispatch:
inputs:
branch:
description: 'Target branch'
required: false
default: 'main'
jobs:
build:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Declare some variables
shell: bash
run: |
sha_short=$(git rev-parse --short $GITHUB_SHA)
commit_date=$(git log -1 --format=%cd --date=format:%Y%m%d)
echo "REPO_TAG=${commit_date}-${sha_short}" >> "$GITHUB_ENV"
- name: Build and push image
uses: docker/build-push-action@v4
with:
context: .
pull: true
push: true
file: Dockerfile
tags: ${{ secrets.DOCKER_USERNAME }}/${{ vars.DOCKER_REPO }}:${{ env.REPO_TAG }}
build-args: |
APT_MIRROR=${{ vars.APT_MIRROR }}
- name: Log out from Docker Hub
run: docker logout