From 3a22ec7ca82d235b23ff6d68569a1dd569a67fe5 Mon Sep 17 00:00:00 2001 From: Ch4s3r Date: Mon, 24 Jun 2024 23:31:27 +0200 Subject: [PATCH] feat: Add buildpacks for building docker image --- .github/workflows/docker.yml | 113 ---------------------------------- .github/workflows/release.yml | 34 +++++----- .github/workflows/testing.yml | 25 ++------ Dockerfile | 38 ------------ docs/changelog.rst | 1 + package.json | 8 ++- 6 files changed, 31 insertions(+), 188 deletions(-) delete mode 100644 .github/workflows/docker.yml delete mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index ffe21504..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: Docker - -on: - push: - tags: - - "*" - workflow_dispatch: - -env: - REGISTRY_IMAGE: mergeability/mergeable - -jobs: - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - platform: - - linux/amd64 - # Failing to build - # - linux/arm/v6 - - linux/arm/v7 - - linux/arm64 - steps: - - name: Prepare - run: | - platform=${{ matrix.platform }} - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV - - - name: Checkout - uses: actions/checkout@v4 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY_IMAGE }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push by digest - id: build - uses: docker/build-push-action@v5 - with: - context: . - platforms: ${{ matrix.platform }} - labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true - cache-from: type=gha,scope=build-${{ matrix.platform }} - cache-to: type=gha,mode=max,scope=build-${{ matrix.platform }} - - - name: Export digest - run: | - mkdir -p /tmp/digests - digest="${{ steps.build.outputs.digest }}" - touch "/tmp/digests/${digest#sha256:}" - - - name: Upload digest - uses: actions/upload-artifact@v4 - with: - name: digests-${{ env.PLATFORM_PAIR }} - path: /tmp/digests/* - if-no-files-found: error - retention-days: 1 - - merge: - runs-on: ubuntu-latest - needs: - - build - steps: - - name: Download digests - uses: actions/download-artifact@v4 - with: - path: /tmp/digests - pattern: digests-* - merge-multiple: true - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY_IMAGE }} - tags: | - # minimal - type=semver,pattern={{version}} - # set latest tag for default branch - type=raw,value=latest,enable={{is_default_branch}} - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Create manifest list and push - working-directory: /tmp/digests - run: | - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - - - name: Inspect image - run: | - docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 00eacd9a..367fdffa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,26 +5,30 @@ on: branches: - master +env: + DOCKER_IMAGE_NAME: mergeability/mergeable + jobs: build: name: Release runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.11.1] - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - run: npm install - - name: Release + - name: Checkout + uses: actions/checkout@v4 + - name: Semantic Release + id: semantic + uses: cycjimmy/semantic-release-action@v4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npx semantic-release + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + if: ${{ steps.semantic.outputs.new_release_version }} + - uses: buildpacks/github-actions/setup-pack@v5.7.2 + if: ${{ steps.semantic.outputs.new_release_version }} + - name: Build and publish docker image + if: ${{ steps.semantic.outputs.new_release_version }} + run: pack build ${{ env.DOCKER_IMAGE_NAME }} -t ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.semantic.outputs.new_release_version }} -t ${{ env.DOCKER_IMAGE_NAME }}:latest -B paketobuildpacks/builder-jammy-tiny -b docker.io/paketobuildpacks/nodejs --publish diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index d6819bdc..e8400523 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,31 +1,16 @@ name: CI -on: - push: - branches: ['**'] - pull_request: - branches: ['**'] - -permissions: - contents: read +on: [ push ] jobs: build: - name: Tests and Code Coverage runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [20.11.1] - steps: - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} + - name: Use Node.js uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} - - run: npm install + node-version: '20.x' + - run: npm ci - run: npm run build --if-present - - run: npm run test-coverage - env: - CI: true + - run: npm test diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 5201990c..00000000 --- a/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# syntax=docker/dockerfile:1 - -# Comments are provided throughout this file to help you get started. -# If you need more help, visit the Dockerfile reference guide at -# https://docs.docker.com/go/dockerfile-reference/ - -# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7 - -ARG NODE_VERSION=18 - -FROM node:${NODE_VERSION}-alpine - -# Use production node environment by default. -ENV NODE_ENV production - - -WORKDIR /usr/src/app - -# Download dependencies as a separate step to take advantage of Docker's caching. -# Leverage a cache mount to /root/.npm to speed up subsequent builds. -# Leverage a bind mounts to package.json and package-lock.json to avoid having to copy them into -# into this layer. -RUN --mount=type=bind,source=package.json,target=package.json \ - --mount=type=bind,source=package-lock.json,target=package-lock.json \ - --mount=type=cache,target=/root/.npm \ - npm ci --omit=dev - -# Run the application as a non-root user. -USER node - -# Copy the rest of the source files into the image. -COPY . . - -# Expose the port that the application listens on. -EXPOSE 3000 - -# Run the application. -CMD npm start diff --git a/docs/changelog.rst b/docs/changelog.rst index 9142ade0..73f0ad03 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,5 +1,6 @@ CHANGELOG ===================================== +| June 25 2024: feat: Add buildpacks for building docker image `#764 `_ | June 20, 2024: feat: Add options 'one_of' and 'none_of'. Support in filters `payload`, `author`, and in action `lastComment` to filter comments authors `#757 `_ | June 20, 2024: feat: Add annotations @sender @bot @repository @action and template helper {{formatDate}} `#756 `_ | June 20, 2024: fix: Comments on Issues should not trigger `checks` action `#759 `_ diff --git a/package.json b/package.json index f2b4a029..e43210e6 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "standard": "^16.0.3" }, "engines": { - "node": ">= 18.12.1" + "node": "^20" }, "standard": { "env": [ @@ -58,5 +58,9 @@ "collectCoverageFrom": [ "lib/**/*.js" ] - } + }, + "publishConfig": { + "access": "public" + }, + "private": false }