diff --git a/.github/workflows/build-docker-image.yaml b/.github/workflows/build-docker-image.yaml new file mode 100644 index 00000000..2d4cbf6b --- /dev/null +++ b/.github/workflows/build-docker-image.yaml @@ -0,0 +1,23 @@ +name: ci + +on: + push: + branches: + - 'master' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: r-webdev + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: ghcr.io/r-webdev/support-bot:stable,ghcr.io/r-webdev/support-bot:latest diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 0c413718..00000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Deploy - -on: - push: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: akhileshns/heroku-deploy@v3.12.12 # This is the action - with: - heroku_api_key: ${{secrets.HEROKU_API_KEY}} - heroku_app_name: "webdev-support-bot" #Must be unique in Heroku - heroku_email: "admin@gerritalex.de" \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..c25ea1d1 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,34 @@ +name: test + +on: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Cache npm dependencies + uses: actions/cache@v3 + env: + cache-name: cache-npm + with: + path: node_modules + key: ${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} + ${{ env.cache-name }}- + + - name: Install dependencies + run: yarn install --frozen-lockfile + + # These are temporarily allowed to fail. + # "Temporarily" + - name: Lint + run: npm run lint + continue-on-error: true + - name: Test + run: npm run test + continue-on-error: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..4d3437cd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM node:16.18.1-alpine AS deps + +WORKDIR /app + +COPY package.json ./ +COPY tsconfig.json ./ +COPY yarn.lock ./ +COPY src ./src + +RUN yarn install --frozen-lockfile +RUN npm run build + +FROM node:16.18.1-alpine + +WORKDIR /app + +ENV NODE_ENV=production + +COPY package.json ./ +COPY yarn.lock ./ +RUN yarn install --frozen-lockfile && rm -rf /usr/local/share/.cache +COPY --from=deps /app/build . + +CMD ["node","index.js"] \ No newline at end of file diff --git a/Procfile b/Procfile deleted file mode 100644 index a124269e..00000000 --- a/Procfile +++ /dev/null @@ -1 +0,0 @@ -worker: node build/index.js \ No newline at end of file diff --git a/package.json b/package.json index 6586a273..66cd9858 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "type": "module", "engines": { - "node": "16.15.0" + "node": "16.18.1" }, "scripts": { "dev": "cross-env TS_NODE_FILES=true TS_NODE_PROJECT=\"./tsconfig.json\" nodemon -r dotenv/config -x node --experimental-specifier-resolution=node --loader ts-node/esm ./src/index.ts",