websoft9/.github/workflows/build_proxy.yml
2023-10-24 16:57:49 +08:00

52 lines
1.6 KiB
YAML

name: NginxProxyManage Build And Push To DockerHub
on:
push:
branches: [main]
paths:
- "docker/proxy/Dockerfile"
jobs:
build:
name: Build Docker image
runs-on: ubuntu-latest
env:
TAGS: latest
steps:
- uses: actions/checkout@v2
name: Check out code
- name: Get version
run: |
version=$(grep -Po '(?<=LABEL version=").*?(?=")' docker/proxy/Dockerfile)
echo $version
real_version=${version%%-*}
echo "VERSION=$version" >> $GITHUB_ENV
if [ "$version" != "$real_version" ]; then
version_list=$version
else
IFS='.' read -ra VERSION_PARTS <<< "$real_version"
version_list="latest"
version_accumulator=""
for i in "${VERSION_PARTS[@]}"; do
if [ -z "$version_accumulator" ]; then
version_accumulator=$i
else
version_accumulator=$version_accumulator.$i
fi
version_list=$version_accumulator,$version_list
done
fi
echo "VERSION_LIST=$version_list" >> $GITHUB_ENV
- uses: mr-smithers-excellent/docker-build-push@v5
name: Build & push Docker image
with:
image: websoft9dev/proxy
tags: ${{ env.VERSION_LIST }}
addLatest: True
registry: docker.io
dockerfile: docker/proxy/Dockerfile
directory: docker/proxy
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}