diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ef60564..7a3ad81 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,10 +10,17 @@ permissions: contents: read jobs: + cancel: + name: ๐Ÿ›‘ Cancel Previous Runs + runs-on: ubuntu-latest + steps: + - uses: styfle/cancel-workflow-action@0.12.1 + test: name: ๐Ÿงช Test + needs: [cancel] runs-on: ubuntu-latest - + services: postgres: image: postgres:15 @@ -30,16 +37,13 @@ jobs: - 5432:5432 steps: - - name: ๐Ÿ›‘ Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - - name: โฌ‡๏ธ Checkout repo uses: actions/checkout@v4 - name: โŽ” Setup node uses: actions/setup-node@v4 with: - node-version: 20 + node-version-file: '.nvmrc' cache: 'npm' - name: ๐Ÿ“ฅ Install dependencies @@ -53,18 +57,16 @@ jobs: typecheck: name: สฆ TypeScript + needs: [cancel] runs-on: ubuntu-latest steps: - - name: ๐Ÿ›‘ Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - - name: โฌ‡๏ธ Checkout repo uses: actions/checkout@v4 - name: โŽ” Setup node uses: actions/setup-node@v4 with: - node-version: 20 + node-version-file: '.nvmrc' cache: 'npm' - name: ๐Ÿ“ฅ Install dependencies @@ -75,18 +77,16 @@ jobs: lint: name: ๐Ÿ” Lint + needs: [cancel] runs-on: ubuntu-latest steps: - - name: ๐Ÿ›‘ Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - - name: โฌ‡๏ธ Checkout repo uses: actions/checkout@v4 - name: โŽ” Setup node uses: actions/setup-node@v4 with: - node-version: 20 + node-version-file: '.nvmrc' cache: 'npm' - name: ๐Ÿ“ฅ Install dependencies @@ -102,24 +102,12 @@ jobs: if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} runs-on: ubuntu-latest steps: - - name: ๐Ÿ›‘ Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - - name: โฌ‡๏ธ Checkout repo uses: actions/checkout@v4 - name: ๐Ÿณ Set up Docker Buildx uses: docker/setup-buildx-action@v3 - # Setup cache - - name: โšก๏ธ Cache Docker layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: ๐Ÿ”“ Login to Container Registry uses: docker/login-action@v3 with: @@ -133,26 +121,14 @@ jobs: context: . push: true tags: ${{ vars.CONTAINER_REGISTRY }}/brackt:latest - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - build-args: | - DATABASE_URL=${{ secrets.PROD_DATABASE_URL }} - - # This ugly bit is necessary if you don't want your cache to grow forever - # till it hits GitHub's limit of 10GB. - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - - name: ๐Ÿšš Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + cache-from: type=gha + cache-to: type=gha,mode=max deploy: name: ๐Ÿš€ Deploy runs-on: ubuntu-latest needs: [build] - # only deploy main/dev branch on pushes + # only deploy main branch on pushes if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} steps: @@ -173,3 +149,9 @@ jobs: cd brackt docker compose pull docker compose up -d + sleep 10 + if docker compose ps | grep -qE "Exit|exited"; then + echo "One or more containers failed to start:" + docker compose logs --tail=50 + exit 1 + fi diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..209e3ef --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +20