2023-09-11 15:19:18 +00:00
|
|
|
name: Build and Push Docker Image
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
2023-09-10 13:21:13 +00:00
|
|
|
|
|
|
|
jobs:
|
2023-09-11 15:19:18 +00:00
|
|
|
build-and-push:
|
2023-09-10 13:21:13 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-09-11 15:19:18 +00:00
|
|
|
|
2023-09-10 13:21:13 +00:00
|
|
|
steps:
|
2023-09-11 15:19:18 +00:00
|
|
|
- name: Checkout Repository
|
2023-09-10 13:21:13 +00:00
|
|
|
uses: actions/checkout@v3
|
2023-09-11 15:19:18 +00:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
|
|
|
- name: Build and Push Docker Image
|
2023-09-10 13:21:13 +00:00
|
|
|
run: |
|
2023-09-11 15:19:18 +00:00
|
|
|
# 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}}
|