-
Notifications
You must be signed in to change notification settings - Fork 2
67 lines (55 loc) · 2.04 KB
/
produce-docker-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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