Skip to content

Commit c50b99a

Browse files
committed
Build and publish container image
1 parent 20b2845 commit c50b99a

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

.github/workflows/CI-build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ on:
44
push:
55
pull_request:
66

7+
env:
8+
REGISTRY: ghcr.io
9+
710
jobs:
811
build:
912
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read # Required for actions/checkout
15+
packages: write # Required to publish docker image
1016

1117
steps:
1218
- name: Checkout code
@@ -34,3 +40,24 @@ jobs:
3440
with:
3541
name: server-app
3642
path: packages/server/dist
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Log in to GitHub container registry
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ${{ env.REGISTRY }}
51+
username: ${{ github.actor }}
52+
password: ${{ github.token }}
53+
54+
- name: Lowercase the repo name and username as container tags must be lowercase
55+
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
56+
57+
- name: Build and push container image to registry
58+
id: push
59+
uses: docker/build-push-action@v5
60+
with:
61+
push: ${{ github.event_name == 'push' }} # always build the container (incl. Pull Requests), but only push to the registry on code push
62+
tags: ${{ env.REGISTRY }}/${{ env.REPO }}:${{ github.sha }}
63+
file: ./Dockerfile

0 commit comments

Comments
 (0)