Skip to content

Commit

Permalink
Add workflow for building images
Browse files Browse the repository at this point in the history
  • Loading branch information
janekbaraniewski committed Apr 28, 2024
1 parent 3acf80b commit 6f5f281
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and Push Docker images

on:
push:
branches:
- master
paths:
- 'src/**'
- 'Dockerfile.server'
- 'Dockerfile.client'

jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
component: [server, client]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and tag the Docker image
run: |
docker build . -f Dockerfile.${{ matrix.component }} \
-t ghcr.io/${{ github.repository }}/${{ matrix.component }}:${{ github.sha }} \
-t ghcr.io/${{ github.repository }}/${{ matrix.component }}:latest
- name: Push Docker images to GitHub Packages
run: |
docker push ghcr.io/${{ github.repository }}/${{ matrix.component }}:${{ github.sha }}
docker push ghcr.io/${{ github.repository }}/${{ matrix.component }}:latest

0 comments on commit 6f5f281

Please sign in to comment.