import { Workflow } from 'cdkactions';
import { DockerPublishJob } from '@pennlabs/kraken';
const workflow = new Workflow(this, 'workflow', {
name: 'Build and Publish',
on: 'push',
});
// Backend API
const backend = new DockerPublishJob(
workflow,
'backend',
{
imageName: 'myapp-backend',
path: './backend',
dockerfile: 'Dockerfile',
tags: 'latest,${{ github.sha }}',
buildArgs: {
DJANGO_SETTINGS_MODULE: 'myapp.settings.production',
},
cache: true,
}
);
// Frontend with custom push condition
new DockerPublishJob(
workflow,
'frontend',
{
imageName: 'myapp-frontend',
path: './frontend',
tags: 'latest,${{ github.sha }},v1.0',
push: "${{ github.ref == 'refs/heads/production' }}",
buildArgs: {
NODE_ENV: 'production',
REACT_APP_API_URL: 'https://api.myapp.com',
},
},
{
// Job overrides
needs: backend.id, // Wait for backend to build first
}
);