Split deployment workflows into 3 different stages #466
Labels
No labels
blocked
duplicate
high priority
needs
approval
needs
criteria
needs
estimate
needs
tests
question
step
doing
step
review
step
testing
step
todo
step
uat
type
admin
type
alert
type
bug
type
change
type
defect
type
dependencies
type
development
type/documentation
type
epic
type
idea
type
incident
type
investigation
type
spike
type
story
type
tests
wontfix
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
External/card-drop#466
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Story points: 5
User story
As an operator, I want deploy workflows split into build → copy → deploy so artifacts are versioned in Forgejo Actions and runtime hosts only receive what the app needs to run.
Current behaviour
stage.ymlandproduction.ymleach have abuildjob that installs/builds/tests/lints then rsyncs the entire checkout to the host, then adeployjob that SSH-restarts MySQL (docker compose) + migrations +pm2.environment: prod.Acceptance criteria
GIVEN a stage or production deploy workflow runs
WHEN the pipeline executes
THEN it has three sequential jobs: build → copy → deploy.
GIVEN the build job
WHEN install/build/test/lint succeed
THEN a lean runtime package is uploaded as a Forgejo Actions artifact (only files required to run: e.g.
dist/,package.json,yarn.lock,docker-compose.yml, and productionnode_modules/— not source/tests/dev-only tree).GIVEN the copy job
WHEN it runs after build
THEN it downloads that artifact and rsyncs it to the existing
STAGE_RSYNC_PATH/PROD_RSYNC_PATH(same SSH/rsync secrets as today).GIVEN the deploy job
WHEN it runs after copy
THEN runtime behaviour matches today: SSH →
docker composedown/up →yarn db:up→pm2restart (card-drop_stage/card-drop_prod), with the same env injection.GIVEN the stage workflow
WHEN the deploy job is configured
THEN it uses Forgejo
environment: stage(notprod).GIVEN triggers
WHEN unchanged branch/tag rules fire
THEN stage still deploys from
develop/hotfix/*/release/*, production from tags.Subtasks
.forgejo/workflows/stage.ymlinto build / copy / deploy jobs.forgejo/workflows/production.ymlthe same wayenvironment: prod→stagedb:up,pm2 start dist/bot.js)Notes
node_modulesfrom the runner (native deps likecanvas) rather than installing on the host, unless we decide otherwise during implementation.rsync --deleteagainst a lean tree will remove old full-checkout files under the rsync root; ensure no required server-only files live there (or add excludes in a follow-up).Planning — criteria locked
Confirmed from owner:
STAGE_RSYNC_PATH/PROD_RSYNC_PATHenvironment: prod→stageImplementation plan
Refactor
.forgejo/workflows/stage.ymlandproduction.ymlto three jobs:yarn install --frozen-lockfile→ build/test/lint → prepare lean tree (dist/,package.json,yarn.lock,docker-compose.yml, productionnode_modules/— prefer prune/reinstall production on the runner so native deps likecanvasmatch the runner) →actions/upload-artifact.needs: build) —actions/download-artifact→ rsync lean tree to existing host path secrets (same rsync action/credentials as today).needs: copy) — existing SSH script unchanged in behaviour; stage job usesenvironment: stage.Triggers and secret/var injection stay as today. Out of scope: excludes hardening, Komodo, app container.
Moved to needs/estimate.
Planning — needs/tests → needs/approval
QA scripts mapped to the acceptance criteria in the issue body. Run after implementation on a branch that triggers stage deploy (e.g.
develop); repeat critical checks on a tag production deploy when ready.Preconditions
STAGE_RSYNC_PATH/PROD_RSYNC_PATH).pm2process name, compose MySQL container, and a smoke Discord command before the change (for deploy regression).AC1 — Three sequential jobs (build → copy → deploy)
.forgejo/workflows/stage.ymlandproduction.ymlon the implementation branchdevelopor manual dispatch per repo rules)needschain)AC2 — Build uploads lean Forgejo Actions artifact
yarn install/ build / test / lint steps run as todaydist/,package.json,yarn.lock,docker-compose.yml, productionnode_modules/— nosrc/, tests, or dev-only toolingAC3 — Copy downloads artifact and rsyncs to host path
STAGE_RSYNC_PATH(stage) orPROD_RSYNC_PATH(prod) using same SSH/rsync secrets as pre-change workflowsdist/,package.json,node_modules/)--deleteis usedyarn db:upandpm2(no missingdist/bot.jsor compose file)AC4 — Deploy job behaviour unchanged
docker composedown/up →yarn db:up→pm2restartcard-drop_stagewith same env injection as beforecard-drop_prodpm2showscard-drop_stageonlineyarn db:upsucceeds against lean tree on hostAC5 — Stage deploy uses
environment: stagestage.ymldeploy jobenvironment: stage(notprod)AC6 — Triggers unchanged
develop(or configured stage branches:hotfix/*,release/*)Out of scope (do not fail QA if deferred)
Sign-off checklist
environmentfix verified.Moving to needs/approval for your review before implementation. @Vylpes