2023-12-20 23:55:41 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
2024-06-15 17:27:54 +00:00
|
|
|
- '[0-9]+\.[0-9]+\.[0-9]+-ulh\.[0-9]+'
|
2023-12-20 23:55:41 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
unlighthouse:
|
2023-12-21 10:39:45 +00:00
|
|
|
runs-on: docker
|
2024-10-21 20:48:04 +00:00
|
|
|
container: forgejo.neshweb.net/ci-docker-images/unlighthouse:0.3.0
|
2024-10-22 15:15:09 +00:00
|
|
|
services:
|
|
|
|
websitecontainer:
|
|
|
|
image: forgejo.neshweb.net/firq/firq-dev-website:preview
|
2023-12-21 01:03:47 +00:00
|
|
|
steps:
|
2023-12-21 10:54:15 +00:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: https://code.forgejo.org/actions/checkout@v3
|
2023-12-20 23:55:41 +00:00
|
|
|
- name: Run unlighthouse
|
2024-10-22 15:19:04 +00:00
|
|
|
run: unlighthouse-ci --site "websitecontainer:8081/" --disable-dynamic-sampling
|
2023-12-21 10:54:15 +00:00
|
|
|
- name: Prepare artifacts
|
|
|
|
run: cp serve.json unlighthouse-reports
|
2023-12-20 23:55:41 +00:00
|
|
|
- name: Upload reports
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: unlighthouse-reports
|
2023-12-20 23:57:26 +00:00
|
|
|
path: unlighthouse-reports/
|
2023-12-21 10:54:15 +00:00
|
|
|
|
|
|
|
deploy-unlighthouse-files:
|
|
|
|
needs: [ unlighthouse ]
|
2024-01-10 10:45:42 +00:00
|
|
|
if: success()
|
2023-12-21 10:54:15 +00:00
|
|
|
runs-on: docker
|
|
|
|
env:
|
|
|
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
|
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
|
|
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:
|
2023-12-21 11:20:39 +00:00
|
|
|
name: unlighthouse-reports
|
2023-12-21 10:54:15 +00:00
|
|
|
path: public
|
|
|
|
- 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: Stop screen session, delete old files
|
|
|
|
uses: https://github.com/appleboy/ssh-action@master
|
|
|
|
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
|
2023-12-21 11:23:10 +00:00
|
|
|
find unlighthouse -maxdepth 1 -printf "%p\n"
|
2023-12-21 10:54:15 +00:00
|
|
|
|
|
|
|
deploy-unlighthouse-site:
|
|
|
|
needs: [ deploy-unlighthouse-files ]
|
2024-01-10 10:45:42 +00:00
|
|
|
if: success()
|
2023-12-21 10:54:15 +00:00
|
|
|
runs-on: docker
|
|
|
|
env:
|
|
|
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
|
|
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
|
|
|
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: 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"
|
2024-01-04 23:07:33 +00:00
|
|
|
screen -ls | grep 'firq_dev-unlighthouse' | awk '{print $1}' | xargs -I % -t screen -X -S % quit
|
2023-12-21 11:23:10 +00:00
|
|
|
cd firq_dev
|
2023-12-21 10:54:15 +00:00
|
|
|
screen -S firq_dev-unlighthouse -dm serve unlighthouse/ -p ${{ secrets.UNLIGHTHOUSE_DEPLOY_PORT }}
|