Unlighthouse rework with docker
All checks were successful
Linting and checking code / get-version (push) Successful in 2s
Linting and checking code / astro-check (push) Successful in 12s
Build and deploy preview site / check-tag (push) Successful in 3s
Build and deploy preview site / checking (push) Successful in 12s
Build and deploy preview site / build-site (push) Successful in 1m5s
Build and deploy preview site / run-unlighthouse (push) Successful in 0s
Build and deploy preview site / create-release (push) Successful in 6s
Build and deploy preview site / auto-deploy-dockge (push) Successful in 22s

This commit is contained in:
Firq 2024-11-01 15:43:20 +01:00
parent 2321c5e5ab
commit 9171fda784
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20
4 changed files with 39 additions and 63 deletions

View file

@ -22,7 +22,11 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: https://code.forgejo.org/actions/checkout@v3 uses: https://code.forgejo.org/actions/checkout@v3
- name: Check availability - name: Check availability
run: curl "http://localhost:8081/" run: |
while [ "$(curl -o /dev/null -s -w '%{http_code}' http://localhost:8081/)" -ne 200 ];
do echo "Waiting...";
sleep 5;
done;
- name: Run unlighthouse - name: Run unlighthouse
run: unlighthouse-ci --site "http://localhost:8081/" run: unlighthouse-ci --site "http://localhost:8081/"
- name: Replace URLs - name: Replace URLs
@ -35,78 +39,43 @@ jobs:
name: unlighthouse-reports name: unlighthouse-reports
path: unlighthouse-reports/ path: unlighthouse-reports/
deploy-unlighthouse-files: build-site:
needs: [ unlighthouse ] needs: [ unlighthouse ]
if: success() if: success()
runs-on: docker runs-on: dind
env:
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
steps: steps:
- name: Install and update ssh + rsync
run: |
which rsync || ( apt update -y && apt install rsync -y)
which ssh-agent || ( apt update -y && apt install openssh-client -y)
- name: Downloading static site artifacts - name: Downloading static site artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: unlighthouse-reports name: unlighthouse-reports
path: public path: public
- name: Install SSH Key - name: Set up Docker Buildx
uses: https://github.com/shimataro/ssh-key-action@v2 uses: docker/setup-buildx-action@v3
- name: Log into Docker Package Registry
uses: docker/login-action@v3
with: with:
key: ${{ secrets.SSH_PRIVATE_KEY }} registry: forgejo.neshweb.net
known_hosts: unnecessary username: ${{ secrets.FORGEJO_USERNAME }}
- name: Adding Known Hosts password: ${{ secrets.FORGEJO_TOKEN }}
run: ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts - name: Build and push to Docker Package Registry
- name: Stop screen session, delete old files uses: docker/build-push-action@v5
uses: https://github.com/appleboy/ssh-action@master
with: with:
host: ${{ env.DEPLOY_HOST }} file: Dockerfile.reports
username: ${{ env.DEPLOY_USER }} push: true
key: ${{ secrets.SSH_PRIVATE_KEY }} tags: forgejo.neshweb.net/firq/firq-dev-website-unlighthouse:latest
script: |
screen -X -S firq_dev-unlighthouse kill
rm -r -f firq_dev/unlighthouse/*
- name: Copy files using rsync
run: rsync -az --stats public/* ${{ env.DEPLOY_USER }}@${{ env.DEPLOY_HOST }}:~/firq_dev/unlighthouse
- name: Check files on deploy target
uses: https://github.com/appleboy/ssh-action@master
with:
host: ${{ env.DEPLOY_HOST }}
username: ${{ env.DEPLOY_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd firq_dev
find unlighthouse -maxdepth 1 -printf "%p\n"
deploy-unlighthouse-site: auto-deploy-dockge:
needs: [ deploy-unlighthouse-files ] needs: [ build-site ]
if: success() if: success()
runs-on: docker runs-on: docker
env: container: forgejo.neshweb.net/firq/dockge-cli:0.1.2
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
steps: steps:
- name: Install and update ssh + rsync - name: Configure Dockge CLI
run: | run: |
which rsync || ( apt update -y && apt install rsync -y) dockge host '${{ vars.DOCKGE_HOST }}'
which ssh-agent || ( apt update -y && apt install openssh-client -y) dockge login --user '${{ secrets.DOCKGE_USER }}' --password '${{ secrets.DOCKGE_CREDENTIAL }}'
- name: Install SSH Key - name: Check status and redeploy
uses: https://github.com/shimataro/ssh-key-action@v2 run: |
with: dockge status firq-dev-unlighthouse
key: ${{ secrets.SSH_PRIVATE_KEY }} dockge update firq-dev-unlighthouse
known_hosts: unnecessary dockge status firq-dev-unlighthouse
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
- name: Start new screen session
uses: https://github.com/appleboy/ssh-action@master
with:
host: ${{ env.DEPLOY_HOST }}
username: ${{ env.DEPLOY_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
PATH="$HOME/.local/bin:$PATH"
screen -ls | grep 'firq_dev-unlighthouse' | awk '{print $1}' | xargs -I % -t screen -X -S % quit
cd firq_dev
screen -S firq_dev-unlighthouse -dm serve unlighthouse/ -p ${{ secrets.UNLIGHTHOUSE_DEPLOY_PORT }}

7
Dockerfile.reports Normal file
View file

@ -0,0 +1,7 @@
FROM forgejo.neshweb.net/ci-docker-images/website-serve:2 AS runtime
ADD public /public
COPY ./serve.json /public/serve.json
EXPOSE 8081
CMD serve public/ -p 8081

View file

@ -1,8 +1,8 @@
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap"; import sitemap from "@astrojs/sitemap";
import astroMetaTags from "astro-meta-tags"; import astroMetaTags from "astro-meta-tags";
import mdx from "@astrojs/mdx";
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({

View file

@ -1,7 +1,7 @@
{ {
"name": "@firq/fgosite", "name": "@firq/fgosite",
"type": "module", "type": "module",
"version": "0.2.0-pre.52", "version": "0.2.0-pre.53",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "astro dev", "dev": "astro dev",