diff --git a/.forgejo/workflows/README.md b/.forgejo/workflows/README.md new file mode 100644 index 0000000..69aeb7b --- /dev/null +++ b/.forgejo/workflows/README.md @@ -0,0 +1,53 @@ +# Forgejo Actions Workflows + +This directory contains CI/CD workflows for the RateMyClient project. + +## docker-build.yml + +Automatically builds and pushes Docker images to the Forgejo Container Registry. + +### What it does: +- Triggers on push to `main` branch +- Builds the Docker image using the Dockerfile +- Pushes to `forgejo.sivic.me/kevinsivic/ratemyclient` +- Tags images with: + - `latest` (for main branch) + - Branch name + - Git commit SHA + - Semantic versions (if tagged) + +### Setup Required: + +1. **Enable Actions in Forgejo:** + - Go to repository Settings → Actions + - Enable Actions for this repository + +2. **Configure Forgejo Runner:** + - Forgejo needs a runner to execute workflows + - Follow: https://forgejo.org/docs/latest/admin/actions/ + +3. **Access Token (Already configured):** + - The workflow uses `${{ secrets.GITEA_TOKEN }}` + - This is automatically provided by Forgejo + +### Image Location: + +After successful build, pull the image: +```bash +docker pull forgejo.sivic.me/kevinsivic/ratemyclient:latest +``` + +### Deploy with the built image: + +Update your docker-compose.yml to use the registry image: +```yaml +services: + web: + image: forgejo.sivic.me/kevinsivic/ratemyclient:latest + # Remove 'build: .' line +``` + +### Manual Trigger: + +You can also trigger builds manually from: +Repository → Actions → Build and Push Docker Image → Run workflow diff --git a/.forgejo/workflows/docker-build.yml b/.forgejo/workflows/docker-build.yml new file mode 100644 index 0000000..25a464f --- /dev/null +++ b/.forgejo/workflows/docker-build.yml @@ -0,0 +1,57 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + REGISTRY: forgejo.sivic.me + IMAGE_NAME: ${{ gitea.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Forgejo Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ gitea.actor }} + password: ${{ secrets.GITEA_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,prefix={{branch}}- + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max