Skip to content

Build and Publish Docker Image #9

Build and Publish Docker Image

Build and Publish Docker Image #9

name: Build and Publish Docker Image
on:
repository_dispatch:
types: [db-updated]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DATABASE_REPO: proofofcloud/database
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout App Repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Checkout Database Repo
uses: actions/checkout@v4
with:
repository: ${{ env.DATABASE_REPO }}
path: temp-database-repo
token: ${{ secrets.ORG_READ_TOKEN }}
- name: Inject Whitelist
run: |
echo "Copying whitelist.csv from database repo..."
cat temp-database-repo/*.csv > ./src/whitelist.csv
rm -rf temp-database-repo
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=sha,format=long
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}