-
Notifications
You must be signed in to change notification settings - Fork 631
49 lines (42 loc) · 1.37 KB
/
docker_build_push.yaml
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
42
43
44
45
46
47
48
49
name: Docker Build and Push
on:
workflow_dispatch:
inputs:
branch:
description: "The branch, tag or SHA to release from"
required: true
default: "master"
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Checkout code
uses: actions/checkout@v2
- name: Get version from main.py
id: get_version
run: |
version=$(grep -oP "__Version__ = '\K[^']+" main.py)
if [ -z "$version" ]; then
echo "Error: Unable to retrieve version from main.py"
exit 1
else
echo "::set-output name=version::$version"
fi
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push Docker image
env:
IMAGE_NAME: kindleear/kindleear
TAG_LATEST: latest
TAG_VERSION: ${{ steps.get_version.outputs.version }}
run: |
docker buildx build --push --platform=linux/amd64,linux/arm64 -t $IMAGE_NAME:$TAG_VERSION -t $IMAGE_NAME:$TAG_LATEST -f docker/Dockerfile .