|
| 1 | +# Overview |
| 2 | + |
| 3 | +This document explains how deployments to our VPS infrastructure work across all repositories. It is intended to help contributors understand our branching model, CI/CD pipeline, and repository setup process. |
| 4 | + |
| 5 | +# Branches |
| 6 | + |
| 7 | +Most of our repositories use two primary branches: |
| 8 | + |
| 9 | +1. develop |
| 10 | +2. master |
| 11 | + |
| 12 | +## `develop` branch |
| 13 | +The develop branch contains ongoing development work and changes that are not yet released to production. |
| 14 | + |
| 15 | +In some repositories, this branch may automatically deploy to a testing or staging environment. For example: |
| 16 | + |
| 17 | +* TJ-Bot – Changes pushed to develop are deployed to a testing server. |
| 18 | + |
| 19 | +This branch should be considered unstable and under active development. |
| 20 | + |
| 21 | +## `master` branch |
| 22 | + |
| 23 | +The `master` branch contains production-ready code that is currently deployed to live environments. |
| 24 | + |
| 25 | +When changes are ready for release: |
| 26 | + |
| 27 | +* `master` is rebased from `develop` |
| 28 | +* Production deployment is triggered after the update |
| 29 | + |
| 30 | +# CI/CD Workflow |
| 31 | +We use [Woodpecker CI](https://woodpecker-ci.org/) on our VPS as our continuous integration and deployment engine. |
| 32 | + |
| 33 | +Woodpecker is configured to trigger when changes are merged into either: |
| 34 | + |
| 35 | +* `develop` |
| 36 | +* `master` |
| 37 | + |
| 38 | +The behavior depends on repository-specific configuration located in `.woodpecker.yml` which is stored in the root of each repository. |
| 39 | + |
| 40 | +## Deployment Responsibilities |
| 41 | + |
| 42 | +By design, our Woodpecker pipelines are intentionally minimal and only handle deployment tasks. Typically, pipelines: |
| 43 | + |
| 44 | +1. Build container images using Gradle’s jib task |
| 45 | +2. Push images to our container registry |
| 46 | +3. Notify Watchtower to restart containers with updated images |
| 47 | + |
| 48 | +## Why We Use Woodpecker CI |
| 49 | + |
| 50 | +We allow multiple GitHub teams to have write access to our repositories. This improves contributor experience by allowing pull requests without requiring repository forks. |
| 51 | + |
| 52 | +However, this model introduces security risks. |
| 53 | + |
| 54 | +### Security Concerns with GitHub Actions |
| 55 | + |
| 56 | +If GitHub Actions were used for deployments: |
| 57 | + |
| 58 | +* Any contributor with write access could potentially create or modify workflows |
| 59 | +* A malicious or compromised account could expose repository secrets (e.g. registry credentials or Watchtower tokens) |
| 60 | +* This could allow attackers to: |
| 61 | + * Push malicious container images |
| 62 | + * Execute remote code |
| 63 | + * Compromise infrastructure |
| 64 | + |
| 65 | +While we trust our contributors, we design our systems with compromise scenarios in mind. |
| 66 | + |
| 67 | +### Benefits of Woodpecker |
| 68 | + |
| 69 | +Woodpecker CI was chosen because: |
| 70 | + |
| 71 | +* Secrets are stored and executed outside GitHub |
| 72 | +* It reduces attack surface from pull request workflows |
| 73 | +* Migration from GitHub Actions was straightforward |
| 74 | +* The project is actively maintained and responsive to security issues |
| 75 | +* It requires minimal operational overhead |
| 76 | + |
| 77 | +# Setting Up CI/CD for a New Repository |
| 78 | + |
| 79 | +Follow these steps to enable deployments for a repository. |
| 80 | + |
| 81 | +## 1. Enable the Repository in Woodpecker |
| 82 | + |
| 83 | +Requirements: |
| 84 | + |
| 85 | +* You must be an organization administrator (Moderator) |
| 86 | + |
| 87 | +Steps: |
| 88 | + |
| 89 | +* BVisit: https://woodpecker.togetherjava.org/repos |
| 90 | +* Click Add repository |
| 91 | +* Locate the repository |
| 92 | +* Click Enable |
| 93 | + |
| 94 | +## 2. Configure Repository Secrets |
| 95 | + |
| 96 | +After enabling the repository, configure required secrets such as: |
| 97 | + |
| 98 | +* Watchtower token |
| 99 | +* Docker registry username |
| 100 | +* Docker registry password |
| 101 | +* Any repository-specific credentials |
| 102 | + |
| 103 | +Secrets are managed inside Woodpecker, not inside GitHub. |
| 104 | + |
| 105 | +## 3. Create a Woodpecker Pipeline |
| 106 | + |
| 107 | +Create a `.woodpecker.yml` file in the repository root directory. |
| 108 | + |
| 109 | +This file defines: |
| 110 | + |
| 111 | +* Build steps |
| 112 | +* Image publishing |
| 113 | +* Deployment triggers |
| 114 | +* Environment-specific behaviour |
| 115 | + |
| 116 | +Pipeline configuration may vary depending on repository requirements. |
0 commit comments