Skip to content

feature/update-web-ui #10

feature/update-web-ui

feature/update-web-ui #10

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.
name: Publish Docker image
env:
IMAGE_NAME: mar10/wsgidav
on:
workflow_dispatch:
inputs:
generateAttestation:
description: "Generate artifact attestation"
required: false
default: false
type: boolean
release:
types: [published]
push:
branches:
- master
- main
- 'release/**'
- 'hotfix/**'
pull_request:
branches:
- master
- main
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# tag with version for releases
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# tag with branch name for pushes to branches
type=ref,event=branch
# tag with pr number for pull requests
type=ref,event=pr
# branch pushes: include branch name
# type=sha,event=branch,prefix={{branch}}-
# everything else: safe prefix
type=sha,prefix=sha-
labels: |
org.opencontainers.image.title=WsgiDAV
org.opencontainers.image.description=Generic and extendable WebDAV server written in Python
org.opencontainers.image.vendor=Martin Wendt
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
# Only push to registry for releases, default branch, and manual triggers
# PRs and feature branches just build for testing
push: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.event_name == 'release' || github.event_name == 'workflow_dispatch') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
if: ${{ inputs.generateAttestation == 'true' && steps.push.outcome == 'success' && steps.push.outputs.digest != '' }}
uses: actions/attest@v4
with:
subject-name: index.docker.io/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true