Basic case

(True story) react project deployment

init-wrangler.sh
#!/bin/bash

sed -i "s/ACCOUNT_ID/$(printenv CLOUDFLARE_ACCOUNT_ID)/" wrangler.toml
sed -i "s/ZONE_ID_STAGE/$(printenv CLOUDFLARE_ZONE_ID_STAGE)/" wrangler.toml

export CLOUDFLARE_API_KEY=$(printenv CLOUDFLARE_API_TOKEN)
export CLOUDFLARE_EMAIL=$(printenv CLOUDFLARE_EMAIL)
install.sh
#!/bin/bash

yarn install --frozen-lockfile
build.sh
#!/bin/bash

cp .env.stage .env
yarn build
push.sh
#!/bin/bash

wrangler deploy --env=stage
deploy.yaml
version: '1.0'
from: 'romainlavabrefairfair/deploy-react'

steps:
    -   name: '@init-wrangler'
        script: '/init-wrangler.sh'

    -   name: '@install'
        script: '/install.sh'
        
    -   name: '@build'
        script: '/build.sh'
        
    -   name: '@push'
        script: '/push.sh'

This in about 50 repositories, then one fine day, we had enough of the slowness of yarn, and we cried, because we had to change 50 repositories. (Yes im stupid)

So, please, store your global script in your docker image (in /app)

And in your repository, you just have

deploy.yaml
version: '1.0'
from: 'romainlavabrefairfair/deploy-react'

steps:
    -   name: '@init-wrangler'
        script: /init-wrangler.sh STAGE

    -   name: '@install'
        script: /install.sh

    -   name: '@build'
        script: /build.sh stage

    -   name: '@push'
        script: /push.sh stage

And if you want to switch from yarn to npm, you just have to change your base image

Last updated