Build and Push Database Docker Image #19
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: Build and Push Database Docker Image | |
on: | |
workflow_dispatch: | |
workflow_call: | |
permissions: | |
packages: write | |
contents: read | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Get versions from __about__.py | |
id: get_version | |
run: | | |
python -c " | |
import os | |
def find_about_file(start_path='src'): | |
for root, dirs, files in os.walk(start_path): | |
if '__about__.py' in files: | |
return os.path.join(root, '__about__.py') | |
return None | |
about_file = find_about_file() | |
if about_file: | |
with open(about_file, 'r') as f: | |
exec(compile(f.read(), about_file, 'exec'), globals()) | |
print(f'version=v{__version__}') | |
else: | |
print('Error: __about__.py not found') | |
" >> $GITHUB_OUTPUT | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
ghcr.io/h3xitsec/h3xrecon/database | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=raw,value=${{ steps.get_version.outputs.version }} | |
type=raw,value=latest | |
- 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 GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push database image | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./ | |
file: ./Dockerfile.database | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/amd64,linux/arm64 |