From dbc6c06b0f7ea41f5ea16a1644d93e7430564fa3 Mon Sep 17 00:00:00 2001 From: Mathieu Moalic Date: Mon, 29 Jan 2024 16:00:47 +0100 Subject: [PATCH] Add github action to build the containers --- backend/.github/dependabot.yml | 10 +++++ backend/.github/workflows/docker-build.yml | 46 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 backend/.github/dependabot.yml create mode 100644 backend/.github/workflows/docker-build.yml diff --git a/backend/.github/dependabot.yml b/backend/.github/dependabot.yml new file mode 100644 index 0000000..b8b8480 --- /dev/null +++ b/backend/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "monthly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/backend/.github/workflows/docker-build.yml b/backend/.github/workflows/docker-build.yml new file mode 100644 index 0000000..15634a5 --- /dev/null +++ b/backend/.github/workflows/docker-build.yml @@ -0,0 +1,46 @@ +on: + workflow_dispatch: + push: + tags: + - "v*" + +name: build-image-push-ghcr + +jobs: + build-image-push-ghcr: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log into ghcr.io + if: github.event_name != 'pull_request' + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get image meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository }} + tags: | + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Build and push image + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}