#!/bin/bash
target=/app/deployments
basedir=/app/contracts
tmptarget=$basedir/deployments

source /app/.envrc

rm -rf $tmptarget

cp -r $target $basedir/

ls $basedir/scripts/getting-started
cd $basedir && ./scripts/getting-started/config.sh
cd $basedir && \
DEPLOYMENT_OUTFILE=$tmptarget/artifact.json \
DEPLOY_CONFIG_PATH=$tmptarget/config.json  \
  forge script scripts/deploy/Deploy.s.sol:Deploy \
    --non-interactive \
    --broadcast --private-key $PRIVATE_KEY \
    --rpc-url $L1_RPC_URL

cp $tmptarget/* $target/