From 6f0a757db2039530aaafa08466aeedbbd2fb4ec3 Mon Sep 17 00:00:00 2001 From: Stan Girard Date: Fri, 28 Jun 2024 16:20:02 +0200 Subject: [PATCH] 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): --- .github/workflows/test-build-image.yml | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/test-build-image.yml diff --git a/.github/workflows/test-build-image.yml b/.github/workflows/test-build-image.yml new file mode 100644 index 000000000..22e013a0d --- /dev/null +++ b/.github/workflows/test-build-image.yml @@ -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 \ No newline at end of file