From 1ffe19b8daf663562c9bdda9e4b5de0c0c15c07b Mon Sep 17 00:00:00 2001 From: Bruno Bernardino Date: Tue, 11 Jun 2024 08:25:16 +0100 Subject: [PATCH] Update Deno + dependencies. Also add docker image build. --- .dvmrc | 2 +- .../workflows/cron-check-subscriptions.yml | 4 +- .github/workflows/cron-cleanup.yml | 4 +- .github/workflows/deploy.yml | 2 +- .github/workflows/docker-image.yml | 49 +++++++++++++++++++ .github/workflows/tests.yml | 4 +- Dockerfile | 2 +- import_map.json | 6 ++- lib/interfaces/database.ts | 4 +- lib/providers/brevo.ts | 2 +- lib/providers/stripe.ts | 2 +- lib/utils.ts | 6 +-- lib/utils_test.ts | 2 +- main_test.ts | 2 +- migrate-db.ts | 2 +- public/ts/encryption_test.ts | 3 +- public/ts/utils_test.ts | 2 +- routes.ts | 2 +- 18 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/docker-image.yml diff --git a/.dvmrc b/.dvmrc index 7d47e59..d724e43 100644 --- a/.dvmrc +++ b/.dvmrc @@ -1 +1 @@ -1.41.0 +1.44.1 diff --git a/.github/workflows/cron-check-subscriptions.yml b/.github/workflows/cron-check-subscriptions.yml index 2724eb4..621a2bd 100644 --- a/.github/workflows/cron-check-subscriptions.yml +++ b/.github/workflows/cron-check-subscriptions.yml @@ -10,10 +10,10 @@ jobs: cron-cleanup: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: denoland/setup-deno@v1 with: - deno-version: v1.41.0 + deno-version: v1.44.1 - env: POSTGRESQL_HOST: ${{ secrets.POSTGRESQL_HOST }} POSTGRESQL_USER: ${{ secrets.POSTGRESQL_USER }} diff --git a/.github/workflows/cron-cleanup.yml b/.github/workflows/cron-cleanup.yml index a1e7597..77124c1 100644 --- a/.github/workflows/cron-cleanup.yml +++ b/.github/workflows/cron-cleanup.yml @@ -10,10 +10,10 @@ jobs: cron-cleanup: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: denoland/setup-deno@v1 with: - deno-version: v1.41.0 + deno-version: v1.44.1 - env: POSTGRESQL_HOST: ${{ secrets.POSTGRESQL_HOST }} POSTGRESQL_USER: ${{ secrets.POSTGRESQL_USER }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3045235..ecb6ef1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,7 +10,7 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Configure SSH run: | mkdir -p ~/.ssh/ diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..bff4063 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,49 @@ +name: "Docker Image" + +on: + workflow_dispatch: + schedule: + # At 06:01 on the 5th of every month. + - cron: "1 6 5 * *" + push: + branches: + - "main" + release: + types: [published] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2753f7a..0923c25 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,10 +6,10 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: denoland/setup-deno@v1 with: - deno-version: v1.41.0 + deno-version: v1.44.1 - run: docker-compose pull - uses: jpribyl/action-docker-layer-caching@v0.1.1 continue-on-error: true diff --git a/Dockerfile b/Dockerfile index 7822066..6c24992 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM denoland/deno:1.41.0 +FROM denoland/deno:1.44.1 EXPOSE 8000 diff --git a/import_map.json b/import_map.json index 7676690..aa95d2f 100644 --- a/import_map.json +++ b/import_map.json @@ -3,6 +3,10 @@ "/": "./", "./": "./", - "std/": "https://deno.land/std@0.217.0/" + "std/assert/assert-equals": "jsr:@std/assert@0.226.0/assert-equals", + "std/assert/assert-not-equals": "jsr:@std/assert@0.226.0/assert-not-equals", + "std/http/file-server": "jsr:@std/http@0.224.4/file-server", + "std/dotenv/load": "jsr:@std/dotenv@0.224.0/load", + "deno/emit": "jsr:@deno/emit@0.41.0" } } diff --git a/lib/interfaces/database.ts b/lib/interfaces/database.ts index 30d969e..cbb9a83 100644 --- a/lib/interfaces/database.ts +++ b/lib/interfaces/database.ts @@ -1,5 +1,5 @@ -import { Client } from 'https://deno.land/x/postgres@v0.17.0/mod.ts'; -import 'std/dotenv/load.ts'; +import 'std/dotenv/load'; +import { Client } from 'https://deno.land/x/postgres@v0.19.3/mod.ts'; const POSTGRESQL_HOST = Deno.env.get('POSTGRESQL_HOST') || ''; const POSTGRESQL_USER = Deno.env.get('POSTGRESQL_USER') || ''; diff --git a/lib/providers/brevo.ts b/lib/providers/brevo.ts index 917160e..852abdd 100644 --- a/lib/providers/brevo.ts +++ b/lib/providers/brevo.ts @@ -1,4 +1,4 @@ -import 'std/dotenv/load.ts'; +import 'std/dotenv/load'; import { helpEmail, IS_UNSAFE_SELF_HOSTED } from '/lib/utils.ts'; diff --git a/lib/providers/stripe.ts b/lib/providers/stripe.ts index 5a91b70..7388fdd 100644 --- a/lib/providers/stripe.ts +++ b/lib/providers/stripe.ts @@ -1,4 +1,4 @@ -import 'std/dotenv/load.ts'; +import 'std/dotenv/load'; import { baseUrl, jsonToFormUrlEncoded } from '/lib/utils.ts'; diff --git a/lib/utils.ts b/lib/utils.ts index 2d7eeb6..7de8fab 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,7 +1,7 @@ -import 'std/dotenv/load.ts'; -import { transpile } from 'https://deno.land/x/emit@0.33.0/mod.ts'; +import 'std/dotenv/load'; +import { serveFile } from 'std/http/file-server'; +import { transpile } from 'deno/emit'; import sass from 'https://deno.land/x/denosass@1.0.6/mod.ts'; -import { serveFile } from 'std/http/file_server.ts'; import header from '/components/header.ts'; import footer from '/components/footer.ts'; diff --git a/lib/utils_test.ts b/lib/utils_test.ts index b6ba641..51c120a 100644 --- a/lib/utils_test.ts +++ b/lib/utils_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from 'std/assert/assert_equals.ts'; +import { assertEquals } from 'std/assert/assert-equals'; import { escapeHtml, generateRandomCode, jsonToFormUrlEncoded, splitArrayInChunks } from './utils.ts'; Deno.test('that escapeHtml works', () => { diff --git a/main_test.ts b/main_test.ts index 751e5d4..3164b60 100644 --- a/main_test.ts +++ b/main_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from 'std/assert/assert_equals.ts'; +import { assertEquals } from 'std/assert/assert-equals'; import { abortController } from './main.ts'; const baseUrl = 'http://localhost:8000'; diff --git a/migrate-db.ts b/migrate-db.ts index 99de0ea..2bbcdb7 100644 --- a/migrate-db.ts +++ b/migrate-db.ts @@ -1,4 +1,4 @@ -import 'std/dotenv/load.ts'; +import 'std/dotenv/load'; import Database, { sql } from '/lib/interfaces/database.ts'; diff --git a/public/ts/encryption_test.ts b/public/ts/encryption_test.ts index 7af9b1c..c43c495 100644 --- a/public/ts/encryption_test.ts +++ b/public/ts/encryption_test.ts @@ -1,4 +1,5 @@ -import { assertEquals, assertNotEquals } from 'std/testing/asserts.ts'; +import { assertEquals } from 'std/assert/assert-equals'; +import { assertNotEquals } from 'std/assert/assert-not-equals'; import { KeyPair } from '/lib/types.ts'; import Encryption from './encryption.ts'; diff --git a/public/ts/utils_test.ts b/public/ts/utils_test.ts index 8eabe0d..387a449 100644 --- a/public/ts/utils_test.ts +++ b/public/ts/utils_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from 'std/assert/assert_equals.ts'; +import { assertEquals } from 'std/assert/assert-equals'; import { dateDiffInDays, formatNumber, SupportedCurrencySymbol, validateEmail } from './utils.ts'; Deno.test('that dateDiffInDays works', () => { diff --git a/routes.ts b/routes.ts index b908b2c..57e2bea 100644 --- a/routes.ts +++ b/routes.ts @@ -1,4 +1,4 @@ -import { serveFile } from 'std/http/file_server.ts'; +import { serveFile } from 'std/http/file-server'; import { baseUrl, basicLayoutResponse, PageContentResult, serveFileWithSass, serveFileWithTs } from './lib/utils.ts'; // NOTE: This won't be necessary once https://github.com/denoland/deploy_feedback/issues/433 is closed