Updated github actions for docker build versioning #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish DockerHub image | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- 'main' | ||
jobs: | ||
build-container: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
${{ github.repository_owner }}/projectzomboid-server | ||
tags: | | ||
Check failure on line 26 in .github/workflows/build.yml
|
||
type=semver,pattern={{version}},value=${{ git describe --tags --abbrev=0 }} | ||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }} | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
- name: Docker Hub Description | ||
uses: peter-evans/dockerhub-description@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
repository: ${{ secrets.DOCKERHUB_USERNAME }}/projectzomboid-server | ||
readme-filepath: ./readme.md | ||
short-description: Project Zomboid Server Docker Image |