Skip to content

Docker Image CI

Docker Image CI #43

name: Docker Image CI
on:
push:
branches: [main]
# Allow manual triggering
workflow_dispatch:
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
BOTS_IMAGE_NAME: ${{ github.repository_owner }}/abbott-bots
WEB_IMAGE_NAME: ${{ github.repository_owner }}/abbott-web
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
# Read the contents of the repository
contents: read
# Allow access to the GitHub container registry
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: make image names lowercase
run: |
echo "BOTS_IMAGE_NAME=${BOTS_IMAGE_NAME@L}" >>${GITHUB_ENV}
echo "WEB_IMAGE_NAME=${WEB_IMAGE_NAME@L}" >>${GITHUB_ENV}
- name: Retrieve date in seconds
run: |
echo "VALUE=$(date +%s)" >> $GITHUB_OUTPUT
id: date_in_seconds
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push the "bots" image
uses: docker/build-push-action@v5.1.0
with:
file: ./packages/bots/Dockerfile
# This should run from the root
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.BOTS_IMAGE_NAME }}:${{ steps.date_in_seconds.outputs.VALUE }}, ${{ env.REGISTRY }}/${{ env.BOTS_IMAGE_NAME }}:latest
- name: Build and push the "web" image
uses: docker/build-push-action@v5.1.0
with:
file: ./packages/web/Dockerfile
# This should run from the root
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.WEB_IMAGE_NAME }}:${{ steps.date_in_seconds.outputs.VALUE }}, ${{ env.REGISTRY }}/${{ env.WEB_IMAGE_NAME }}:latest