6437f01434
- Change Docker Hub image name to christianlouis/docuelevate - Update GHCR references to use docuelevate - Ensure consistency across all Docker build tags Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
81 lines
2.3 KiB
YAML
81 lines
2.3 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- develop
|
|
tags:
|
|
- 'v*'
|
|
- '[0-9]+.*'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
IMAGE_NAME: christianlouis/docuelevate
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Generate Build Metadata
|
|
run: |
|
|
chmod +x scripts/generate_build_metadata.sh
|
|
./scripts/generate_build_metadata.sh
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract Git Tag (if applicable)
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
|
|
|
- name: Extract metadata for tags
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.IMAGE_NAME }}
|
|
ghcr.io/${{ github.repository_owner }}/docuelevate
|
|
|
|
- name: Build and Push Docker Image with Provenance and SBOM
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: Dockerfile
|
|
platforms: linux/amd64
|
|
push: true
|
|
sbom: true
|
|
provenance: mode=max
|
|
tags: |
|
|
${{ env.IMAGE_NAME }}:latest
|
|
${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
ghcr.io/${{ github.repository_owner }}/docuelevate:latest
|
|
ghcr.io/${{ github.repository_owner }}/docuelevate:${{ github.sha }}
|
|
${{ startsWith(github.ref, 'refs/tags/') && format('{0}:{1}', env.IMAGE_NAME, env.VERSION) || '' }}
|
|
${{ startsWith(github.ref, 'refs/tags/') && format('ghcr.io/{0}/docuelevate:{1}', github.repository_owner, env.VERSION) || '' }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|