diff --git a/.gitea/workflows/build-and-push.yml b/.gitea/workflows/build-and-push.yml new file mode 100644 index 0000000..c841a5c --- /dev/null +++ b/.gitea/workflows/build-and-push.yml @@ -0,0 +1,50 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: gitea.purpleraft.com + username: ${{ gitea.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: gitea.purpleraft.com/${{ gitea.repository }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=raw,value=latest,enable={{is_default_branch}} + type=sha,prefix={{branch}}- + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/README.md b/README.md index 464e44d..8854b42 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,35 @@ Please be aware that this will not persist any data. | `POSTGRESQL_PASSWORD` | | - | +## Gitea Actions CI/CD + +This repository includes a Gitea Actions workflow that automatically builds and pushes the Docker image to your Gitea container registry. + +### Setup Instructions + +1. **Create a Personal Access Token:** + - Go to your Gitea instance: https://gitea.purpleraft.com/ + - Navigate to Settings → Applications → Generate New Token + - Create a token with `write:packages` permission + - Copy the token value + +2. **Add Repository Secret:** + - Go to your repository settings + - Navigate to Secrets and Variables → Actions + - Add a new secret named `GITEA_TOKEN` with your personal access token as the value + +3. **Enable Actions (if not already enabled):** + - Ensure Gitea Actions are enabled in your repository settings + - The workflow will trigger on pushes to main/master branches and pull requests + +### Workflow Features + +- Builds Docker image using Docker Buildx +- Pushes to `gitea.purpleraft.com/{username}/{repository}` +- Creates multiple tags: branch name, latest (for default branch), and commit SHA +- Uses GitHub Actions cache for faster builds +- Runs on pushes and pull requests + ## To Do - Figure out where the pictures are stored - Write some setup instructions