Unlighthouse rework with docker

This commit is contained in:
Firq 2024-11-01 15:43:20 +01:00
parent 2321c5e5ab
commit b72a4ddd4a
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
uses: https://code.forgejo.org/actions/checkout@v3
- 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
run: unlighthouse-ci --site "http://localhost:8081/"
- name: Replace URLs
@ -35,78 +39,43 @@ jobs:
name: unlighthouse-reports
path: unlighthouse-reports/
deploy-unlighthouse-files:
build-site:
needs: [ unlighthouse ]
if: success()
runs-on: docker
env:
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
runs-on: dind
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
uses: actions/download-artifact@v3
with:
name: unlighthouse-reports
path: public
- name: Install SSH Key
uses: https://github.com/shimataro/ssh-key-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into Docker Package Registry
uses: docker/login-action@v3
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: unnecessary
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
- name: Stop screen session, delete old files
uses: https://github.com/appleboy/ssh-action@master
registry: forgejo.neshweb.net
username: ${{ secrets.FORGEJO_USERNAME }}
password: ${{ secrets.FORGEJO_TOKEN }}
- name: Build and push to Docker Package Registry
uses: docker/build-push-action@v5
with:
host: ${{ env.DEPLOY_HOST }}
username: ${{ env.DEPLOY_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
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"
file: Dockerfile.reports
push: true
tags: forgejo.neshweb.net/firq/firq-dev-website-unlighthouse:latest
deploy-unlighthouse-site:
needs: [ deploy-unlighthouse-files ]
auto-deploy-dockge:
needs: [ build-site ]
if: success()
runs-on: docker
env:
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
container: forgejo.neshweb.net/firq/dockge-cli:0.1.2
steps:
- name: Install and update ssh + rsync
- name: Configure Dockge CLI
run: |
which rsync || ( apt update -y && apt install rsync -y)
which ssh-agent || ( apt update -y && apt install openssh-client -y)
- name: Install SSH Key
uses: https://github.com/shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: unnecessary
- 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 }}
dockge host '${{ vars.DOCKGE_HOST }}'
dockge login --user '${{ secrets.DOCKGE_USER }}' --password '${{ secrets.DOCKGE_CREDENTIAL }}'
- name: Check status and redeploy
run: |
dockge status firq-dev-unlighthouse
dockge update firq-dev-unlighthouse
dockge status firq-dev-unlighthouse

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 mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import astroMetaTags from "astro-meta-tags";
import mdx from "@astrojs/mdx";
// https://astro.build/config
export default defineConfig({

View file

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