diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index 74f9e723172..21abfeb8432 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -55,8 +55,6 @@ jobs: deploy: needs: [build] runs-on: ubuntu-latest - env: - HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} steps: - name: Set Heroku app name based on branch id: set-heroku-app-name @@ -82,22 +80,10 @@ jobs: esac echo "HEROKU_APP_NAME=$APP_NAME" >> $GITHUB_ENV - - name: Extract branch name - shell: bash - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT - id: extract_branch - - uses: actions/checkout@v2 - with: - ref: ${{ steps.extract_branch.outputs.branch }} - - - name: Setup tmate session - uses: mxschmitt/action-tmate@v3 - uses: akhileshns/heroku-deploy@v3.13.15 with: - dontuseforce: 1 heroku_api_key: ${{secrets.HEROKU_API_TOKEN}} heroku_app_name: ${{ env.HEROKU_APP_NAME }} - heroku_email: ${{secrets.HEROKU_EMAIL}} - branch: ${{ steps.extract_branch.outputs.branch }} \ No newline at end of file + heroku_email: ${{secrets.HEROKU_EMAIL}} \ No newline at end of file diff --git a/package.json b/package.json index 40999d3b1c5..742b6dc1279 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,6 @@ "prettier-plugin-organize-imports": "^4.0.0", "process": "^0.11.10", "readline-sync": "^1.4.10", - "sequelize-cli": "^6.2.0", "sharp": "^0.31.2", "sinon": "^15.0.4", "source-map-support": "^0.5.21", diff --git a/packages/commonwealth/Procfile b/packages/commonwealth/Procfile index 8ab74703ffe..1aad9c471a4 100644 --- a/packages/commonwealth/Procfile +++ b/packages/commonwealth/Procfile @@ -1,6 +1,6 @@ -web: cd packages/commonwealth && NODE_ENV=production NODE_OPTIONS=--max-old-space-size=$(../../scripts/get-max-old-space-size.sh) node --import=extensionless/register --enable-source-maps ./build/server.js +web: cd packages/commonwealth && ./scripts/heroku-release.sh consumer: cd packages/commonwealth && node --import=extensionless/register --max-old-space-size=$(../../scripts/get-max-old-space-size.sh) build/server/workers/commonwealthConsumer/commonwealthConsumer.js evm-ce: cd packages/commonwealth && node --import=extensionless/register --max-old-space-size=$(../../scripts/get-max-old-space-size.sh) build/server/workers/evmChainEvents/startEvmPolling.js knock: cd packages/commonwealth && node --import=extensionless/register --max-old-space-size=$(../../scripts/get-max-old-space-size.sh) build/server/workers/knock/knockWorker.js message-relayer: cd packages/commonwealth && node --import=extensionless/register --max-old-space-size=$(../../scripts/get-max-old-space-size.sh) build/server/workers/messageRelayer/messageRelayer.js -release: cd packages/commonwealth && node --import=extensionless/register --max-old-space-size=$(../../scripts/get-max-old-space-size.sh) build/server/scripts/releasePhaseEnvCheck.js && npx sequelize-cli db:migrate --config server/sequelize.json && node --import=extensionless/register build/server/scripts/purgeCloudflareCache.js +release: echo "do nothing" \ No newline at end of file diff --git a/packages/commonwealth/scripts/heroku-release.sh b/packages/commonwealth/scripts/heroku-release.sh new file mode 100644 index 00000000000..54416f53887 --- /dev/null +++ b/packages/commonwealth/scripts/heroku-release.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +echo "Logging in to AWS ECR..." +aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com + +IMAGE_URI="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${REPOSITORY_NAME}:${COMMIT_HASH}" + +echo "Pulling Docker image $IMAGE_URI..." +docker pull $IMAGE_URI + +docker run -d -p 8080:8080 $IMAGE_URI +CONTAINER_ID=$(docker run -d -p 8080:8080 $IMAGE_URI) + +echo "Waiting for container to start..." +until [ "`docker inspect -f {{.State.Running}} CONTAINERNAME`"=="true" ]; do + sleep 0.1; +done; + +echo "Running release script" +docker exec -it $CONTAINER_ID pnpm run release diff --git a/packages/commonwealth/server/scripts/releasePhaseEnvCheck.ts b/packages/commonwealth/server/scripts/releasePhaseEnvCheck.js similarity index 78% rename from packages/commonwealth/server/scripts/releasePhaseEnvCheck.ts rename to packages/commonwealth/server/scripts/releasePhaseEnvCheck.js index b64561a8ff3..d17a3a96158 100644 --- a/packages/commonwealth/server/scripts/releasePhaseEnvCheck.ts +++ b/packages/commonwealth/server/scripts/releasePhaseEnvCheck.js @@ -8,12 +8,10 @@ if (import.meta.url.endsWith(process.argv[1])) { // TODO: Add checks for unused env var // TODO: Add warning for manually set client FLAGs when APP_ENV !== 'local'/'CI' log.info('Environment variables are properly configured'); - // eslint-disable-next-line @typescript-eslint/no-floating-promises dispose()('EXIT', true); }) .catch((err) => { log.fatal('Environment variables not properly configured!', err); - // eslint-disable-next-line @typescript-eslint/no-floating-promises dispose()('ERROR', true); }); } diff --git a/temp.txt b/temp.txt new file mode 100644 index 00000000000..e69de29bb2d