-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (35 loc) · 1.01 KB
/
python-docker.yml
File metadata and controls
41 lines (35 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Build Python Docker Image
on:
workflow_call:
inputs:
docker_image:
required: true
type: string
docker_tag:
required: false
default: ""
type: string
secrets:
docker_username:
docker_password:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out Code
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
- name: Build Docker Image
run: |
TAG=${{ inputs.docker_tag }}
if [ -z "$TAG" ]; then TAG=${{ github.sha }}; fi # Use commit hash if no tag is provided
docker build -t ${{ inputs.docker_image }}:$TAG .
- name: Push Docker Image
run: |
TAG=${{ inputs.docker_tag }}
if [ -z "$TAG" ]; then TAG=${{ github.sha }}; fi
docker push ${{ inputs.docker_image }}:$TAG