chore: Add GitHub Actions workflow for testing and building Docker image (#2778)

# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
This commit is contained in:
Stan Girard 2024-06-28 16:20:02 +02:00 committed by GitHub
parent 12e694a62d
commit 6f0a757db2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

46
.github/workflows/test-build-image.yml vendored Normal file
View File

@ -0,0 +1,46 @@
name: Test Build Image
on:
pull_request:
branches: ["main"]
paths:
- 'backend/**'
jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest
strategy:
matrix:
platform: [linux/amd64, linux/arm64]
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Login to GitHub Container Registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3
- name: Create Docker Cacha Storage Backend
run: |
docker buildx create --use --driver=docker-container
- name: Build image
id: build-image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
with:
context: ./backend/
platforms: ${{ matrix.platform }}
cache-from: type=gha
cache-to: type=gha,mode=max