forgejo-deployment/ci/buildspec.yml
Daisuke 058d1be93f feat(ci/cd): Add artifact bucket and ECS deployment support
- Create S3 artifact bucket with encryption and versioning
- Add ECR lifecycle policy to maintain maximum 5 images
- Add OutputArtifacts to build stage for deployment
- Add Deploy stage with ECS provider
- Update CodePipeline artifact store to use ArtifactBucket
- Replace hardcoded bucket names with parameterized references
- Add IAM permissions for ECS task definition and service management
- Add buildspec commands to generate image definitions file
2026-01-10 19:39:15 +09:00

21 lines
807 B
YAML

version: 0.2
phases:
pre_build:
commands:
- set -e
- ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
- REPOSITORY_URI=${ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/forgejo-repository
- aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${REPOSITORY_URI}
- GIT_TAG=$(date +%s)
build:
commands:
- set -e
- docker build -t ${REPOSITORY_URI}:${GIT_TAG} -t ${REPOSITORY_URI}:latest .
post_build:
commands:
- set -e
- docker push ${REPOSITORY_URI}:${GIT_TAG}
- docker push ${REPOSITORY_URI}:latest
- printf '[{"name":"forgejo","imageUri":"%s"}]' $REPOSITORY_URI:$GIT_TAG > imagedefinitions.json
artifacts:
files: imagedefinitions.json