Простой способ перебилдить проект по тригеру

Тут описан простой прием как обновить что-то, что находится на сервере с nginx. Для этого достаточно запустить простой bash скрипт, который следит за изменением на чтение и запись определенного файла. В случае чтения, он выполняет обновление (например, стягивание с гита и сборку).

#!/bin/bash

inotifywait -m -e access -e modify update-trigger |
while read path action file;
do
	echo "trigger $action"

	if [ "$action" == "MODIFY" ];
	then
		echo "Exit";
		exit 1;	

	fi

	T=$(date)
	echo "[$T] start_build"
	git submodule foreach git pull # origin master
	make build-non-interactive 
	T=$(date)
	echo "[$T] finish_build"
done
watch

Рядом с файлом watch должен лежать файл update-trigger.

В случае изменения файла update-trigger (например, так date -Isec > update-trigger) – завершает цикл обработки.

Найстройка nginx:

server {
    listen 0.0.0.0:80;
    server_name 123.xyz;
    access_log /var/log/nginx/123_xyz_access.log;
    error_log /var/log/nginx/123_xyz_error.log;

    location /update-trigger-[SOME_RANDOM_TOKEN] {
        alias /var/www/v2/123_xyz/update-trigger;
    }
}
update-trigger.conf

Данный прием можно использовать при обновлении исходников из гитхаба через github actions:

# This is a basic workflow to help you get started with Actions

name: update-dev-call

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Runs a single command using the runners shell
      - name: HTTP request for update dev docs
        run: curl https://${{ secrets.TARGET_HOST }}/update-trigger-${{ secrets.RANDOM_KEY }}
update-dev-call.yml

Обратите внимание, что кто угодно может обратиться к урлу, поэтому используйте рандомную строку в nginx location и https.