Skip to content

Publish Dockerimage

Publish Dockerimage #7

name: Publish Dockerimage
on:
workflow_dispatch:
inputs:
version:
description: "Version to publish"
required: true
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
branches:
- 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
if: github.ref == 'refs/heads/main' && (github.ref_type == 'tag' || github.event_name == 'workflow_dispatch')
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Extract tag name
id: tag
shell: bash
run: |
if [[ ${{ github.ref }} == refs/tags/* ]]; then
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "tag=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
id: push
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
push: true
target: app_prod
tags: |
digitalenvironments/hawki:latest
digitalenvironments/hawki:${{ steps.tag.outputs.tag }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: index.docker.io/digitalenvironments/hawki
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true