// todo: put these into `Substitution variables`
// Refs: https://github.com/TexteaInc/PyDataFront
const funixEntryPoint = 'python3 -m pydatafront main';
const deployRegion = 'us-central1'; // iowa
const gcrHostname = 'gcr.io';
const platform = 'managed';
export const createFunixBuildSteps = (repoId, cloudRunServiceName, _config) => {
    const dockerImageUrl = `${gcrHostname}/$PROJECT_ID/${repoId}/${cloudRunServiceName}:$COMMIT_SHA`;
    return {
        tags: [
            'redstone-auto-deploy',
            cloudRunServiceName
        ],
        images: [
            // push to Google Container Registry
            dockerImageUrl
        ],
        steps: [
            // todo(himself65): check whether user already have `requirements.txt` before step 1?
            // step 1: build Funix
            {
                name: 'gcr.io/k8s-skaffold/pack',
                id: 'build-pack',
                entrypoint: 'pack',
                env: [
                    `GOOGLE_ENTRYPOINT=${funixEntryPoint}`
                ],
                args: [
                    'build',
                    dockerImageUrl,
                    '--builder=gcr.io/buildpacks/builder:v1',
                    '--network=cloudbuild',
                    '--path=.',
                    '--env=GOOGLE_ENTRYPOINT'
                ]
            },
            // step 2: push to Google Container Registry
            //  Does this conflict with 'build.images'?
            {
                name: 'gcr.io/cloud-builders/docker',
                args: [
                    'push',
                    dockerImageUrl
                ]
            },
            // step 3: push to Google Cloud Run by service name
            {
                name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:slim',
                id: 'deploy',
                entrypoint: 'gcloud',
                args: [
                    'run',
                    'services',
                    'update',
                    cloudRunServiceName,
                    `--platform=${platform}`,
                    `--image=${dockerImageUrl}`,
                    `--region=${deployRegion}`
                ]
            }
        ]
    };
};
//# sourceMappingURL=funix-build-steps.js.map