From 83661b9d3830512ab37701c3d5e5f0294bbdefae Mon Sep 17 00:00:00 2001 From: Firq Date: Thu, 21 Dec 2023 00:16:39 +0100 Subject: [PATCH] Implemented forgejo ci --- .forgejo/workflows/build_preview.yml | 67 ++++++++++++++++++++++++++++ .forgejo/workflows/build_release.yml | 53 ++++++++++++++++++++++ .forgejo/workflows/linting.yml | 16 +++++++ Dockerfile | 17 +++++++ package.json | 2 +- unlighthouse.config.ts | 2 - 6 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 .forgejo/workflows/build_preview.yml create mode 100644 .forgejo/workflows/build_release.yml create mode 100644 .forgejo/workflows/linting.yml create mode 100644 Dockerfile diff --git a/.forgejo/workflows/build_preview.yml b/.forgejo/workflows/build_preview.yml new file mode 100644 index 0000000..fa48145 --- /dev/null +++ b/.forgejo/workflows/build_preview.yml @@ -0,0 +1,67 @@ +on: + push: + tags: + - '[0-9]+\.[0-9]+\.[0-9]+pre[0-9]+' + +jobs: + checking: + runs-on: docker + container: node:lts + steps: + - name: Checkout source code + uses: https://code.forgejo.org/actions/checkout@v3 + - name: Install packages + run: npm install + - name: Run astro check (linting + static analysis) + run: npm run astro check + + build-site: + needs: [checking] + if: success() + runs-on: dind + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: forgejo.neshweb.net + username: ${{ secrets.FORGEJO_USERNAME }} + password: ${{ secrets.FORGEJO_TOKEN }} + - name: Push to Package Registry + uses: docker/build-push-action@v5 + with: + push: true + tags: forgejo.neshweb.net/firq/firq-dev-website:${{ github.ref_name }}, forgejo.neshweb.net/firq/firq-dev-website:preview + + publish: + needs: [build-site] + if: success() + runs-on: docker + steps: + - name: Release New Version + uses: actions/forgejo-release@v1 + with: + direction: upload + url: https://forgejo.neshweb.net + release-dir: release + token: ${{ secrets.FORGEJO_TOKEN }} + tag: ${{ github.ref_name }} + + unlighthouse: + needs: [publish] + if: success() + runs-on: docker + services: + website: + image: forgejo.neshweb.net/firq/firq-dev-website:preview + steps: + - name: Install Dependencies + run: npm install -g @unlighthouse/cli puppeteer + - name: Run unlighthouse + run: unlighthouse-ci --site website:8081 + - name: Upload reports + uses: actions/upload-artifact@v3 + with: + name: unlighthouse-reports + path: unlighthouse-reports/ diff --git a/.forgejo/workflows/build_release.yml b/.forgejo/workflows/build_release.yml new file mode 100644 index 0000000..258869a --- /dev/null +++ b/.forgejo/workflows/build_release.yml @@ -0,0 +1,53 @@ +on: + push: + tags: + - '[0-9]+\.[0-9]+\.[0-9]+' + - '[0-9]+\.[0-9]+\.[0-9]+a[0-9]+' + - '[0-9]+\.[0-9]+\.[0-9]+b[0-9]+' + - '[0-9]+\.[0-9]+\.[0-9]+rc[0-9]+' + +jobs: + checking: + runs-on: docker + container: node:lts + steps: + - name: Checkout source code + uses: https://code.forgejo.org/actions/checkout@v3 + - name: Install packages + run: npm install + - name: Run astro check (linting + static analysis) + run: npm run astro check + run: npm run astro check + + build-site: + needs: [checking] + if: success() + runs-on: dind + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: forgejo.neshweb.net + username: ${{ secrets.FORGEJO_USERNAME }} + password: ${{ secrets.FORGEJO_TOKEN }} + - name: Push to Package Registry + uses: docker/build-push-action@v5 + with: + push: true + tags: forgejo.neshweb.net/firq/firq-dev-website:${{ github.ref_name }}, forgejo.neshweb.net/firq/firq-dev-website:latest + + release: + needs: [build-site] + if: success() + runs-on: docker + steps: + - name: Release New Version + uses: actions/forgejo-release@v1 + with: + direction: upload + url: https://forgejo.neshweb.net + release-dir: release + token: ${{ secrets.FORGEJO_TOKEN }} + tag: ${{ github.ref_name }} diff --git a/.forgejo/workflows/linting.yml b/.forgejo/workflows/linting.yml new file mode 100644 index 0000000..b759eae --- /dev/null +++ b/.forgejo/workflows/linting.yml @@ -0,0 +1,16 @@ +on: + push: + branches: + - "**" + +jobs: + checking: + runs-on: docker + container: node:lts + steps: + - name: Checkout source code + uses: https://code.forgejo.org/actions/checkout@v3 + - name: Install packages + run: npm install + - name: Run astro check (linting + static analysis) + run: npm run astro check diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e3fd1ee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM node:lts AS build +WORKDIR /app +COPY . . +RUN npm i +RUN npm run build + +FROM node:lts AS runtime +RUN npm install --global "@warren-bank/serve" + +COPY --from=build /app/dist /public +COPY --from=build /app/serve.json /public/serve.json +RUN rm -r /public/assets/data/ + +ENV PORT 8081 +EXPOSE 8081 + +CMD [ "serve", "public/", "-p", "8081" ] diff --git a/package.json b/package.json index 7e0c769..37bdf2d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@firq/fgosite", "type": "module", - "version": "0.1.6", + "version": "0.1.7", "private": true, "scripts": { "dev": "astro dev", diff --git a/unlighthouse.config.ts b/unlighthouse.config.ts index fbd6208..d289ab5 100644 --- a/unlighthouse.config.ts +++ b/unlighthouse.config.ts @@ -1,5 +1,4 @@ export default { - site: 'staging.firq.dev', puppeteerOptions: { args: ["--no-sandbox", "--disable-setuid-sandbox"], }, @@ -7,6 +6,5 @@ export default { budget: 90, buildStatic: true }, - auth: { username: "staging", password: "staging" }, outputPath: "unlighthouse-reports", }