From c85551e2cf0d7a65a04f0ab4ae3b876e5687dea6 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Thu, 18 Jan 2024 02:55:31 +0100 Subject: [PATCH] feat: add CD workflow --- .gitea/workflows/publish-docker.yaml | 40 ++++++++++++++++++++++++++++ Dockerfile | 5 ++-- 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .gitea/workflows/publish-docker.yaml diff --git a/.gitea/workflows/publish-docker.yaml b/.gitea/workflows/publish-docker.yaml new file mode 100644 index 0000000..d665314 --- /dev/null +++ b/.gitea/workflows/publish-docker.yaml @@ -0,0 +1,40 @@ +name: Create and publish a Docker image + +on: + push: + branches: ['main', 'feature/cd'] + +env: + REGISTRY: labs.phundrak.com + IMAGE_NAME: ${{ gitea.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index ebd4de6..da12d80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,8 +50,7 @@ RUN --mount=type=bind,source=src,target=src \ --mount=type=cache,target=/usr/local/cargo/registry/ \ <