54 lines
1.4 KiB
YAML
54 lines
1.4 KiB
YAML
name: Build and Push to Docker Hub
|
|
|
|
on:
|
|
push:
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Calculate Tags
|
|
env:
|
|
ref: ${{ github.ref }}
|
|
repo: ${{ github.repository }}
|
|
run: |
|
|
ref=${ref##*/}
|
|
if [[ $ref == master ]]; then
|
|
tags=$repo:unstable
|
|
elif [[ $ref =~ ^([0-9.]+)-((([0-9]+[.])[0-9]+[.])([.][0-9+])*)$ ]]; then
|
|
upstream=${BASH_REMATCH[1]}
|
|
minor=${BASH_REMATCH[3]}x
|
|
major=${BASH_REMATCH[4]}x
|
|
tags=$repo:latest,$repo:$ref,$repo:$upstream-$minor,$repo:$upstream-$major,$repo:$upstream
|
|
else
|
|
echo "Bad tag: $ref"
|
|
exit 1
|
|
fi
|
|
|
|
echo "$tags"
|
|
echo "build_tags=$tags" >> $GITHUB_ENV
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Build and push
|
|
id: build
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ env.build_tags }}
|
|
|
|
- name: Update repo description
|
|
uses: peter-evans/dockerhub-description@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
repository: ${{ github.repository }}
|