From b86c108082694c717e64aeb885b6a8ffd3dfff63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Mon, 11 Sep 2023 15:19:18 +0000 Subject: [PATCH] CI: try building and pushing container image --- .gitea/workflows/rebuild.yml | 43 +++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/rebuild.yml b/.gitea/workflows/rebuild.yml index af7e199..449b567 100644 --- a/.gitea/workflows/rebuild.yml +++ b/.gitea/workflows/rebuild.yml @@ -1,16 +1,39 @@ -name: Rebuild Gitea container -run-name: ${{ gitea.actor }} is testing actions -on: [push] +name: Build and Push Docker Image + +on: + push: + branches: + - main jobs: - Build container image: + build-and-push: runs-on: ubuntu-latest + steps: - - run: echo "Trigged by ${{ gitea.event_name }}" - - run: echo "Name of branch is ${{ gitea.ref }} and repository ${{ gitea.repository }}" - - name: Check out repository code + - name: Checkout Repository uses: actions/checkout@v3 - - name: List all files + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and Push Docker Image run: | - ls ${{ gitea.workspace }} - - run: echo "Status is ${{ job.status }}" + # Set your Docker registry and image name + REGISTRY_NAME="git.kucharczyk.xyz/${DOCKER_USERNAME}/containers/gitea" + # Optionally, set a tag for your image (e.g., a commit SHA) + #TAG="${{ gitea.sha }}" + TAG="latest" + + # Build the Docker image + docker buildx create --use + docker buildx build --file Dockerfile -t "${REGISTRY_NAME}:${TAG}" . + + # Log in to the container registry (replace with your authentication method) + docker login -u "${{ gitea.repository_owner }}" -p "$DOCKER_PASSWORD" your-registry-url.com + + # Push the image to the container registry + docker push "${REGISTRY_NAME}:${TAG}" + + env: + DOCKER_USERNAME: ${{ gitea.repository_owner }} + DOCKER_PASSWORD: ${{ secrets.GITEA_TOKEN}}