Create docker.yml

This commit is contained in:
Darren 2022-11-07 08:06:24 +08:00 committed by GitHub
parent 6bb893f3eb
commit 79b7133526
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

45
.github/workflows/docker.yml vendored Normal file
View file

@ -0,0 +1,45 @@
name: Docker Build And Push To Docker Hub
on:
push:
branches: [ main ]
paths:
- 'Dockerfile'
- 'cmd.sh'
- 'entrypoint.sh'
tags:
- v**
jobs:
build:
name: Build Docker image
runs-on: ubuntu-latest
env:
TAGS: latest
steps:
- uses: actions/checkout@v2
name: Check out code
- name: Set appname
run: |
repo=${{github.event.repository.name}}
arrayrepo=(${repo//-/ })
APP_NAME=${arrayrepo[1]}
echo "APP_NAME=${APP_NAME}" >> $GITHUB_ENV
- name: Get all tags when release a tag
if: contains(github.ref_name, 'v')
run: |
tmptag=${{ github.ref_name}}
arraytag=(${tmptag//./ })
TAGS=${arraytag[0]},${arraytag[0]}.${arraytag[1]},${{ github.ref_name}},latest
echo "TAGS=${TAGS}" >> $GITHUB_ENV
- uses: mr-smithers-excellent/docker-build-push@v5
name: Build & push Docker image
with:
image: websoft9dev/${{env.APP_NAME}}
tags: ${{env.TAGS}}
registry: docker.io
dockerfile: Dockerfile
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}