The Action Interface (actint) is a simple web service that touches a file for the called action.
For example if the action .deploy
is called it touches a file into the /do
folder inside
the docker container. You can configure a volume to mount the /do
folder to and use this
as a kind of a postbox to see what action to was triggered using the web service.
It is built with the intention, that it can be used in Git workflows to trigger an action on a deployment host.
The following environment variable can be used ton configure acint
.
A comma separated list of actions to allow, default: .deploy
ACINT_ALLOWED_ACTIONS=.deploy
The security token to be used to authenticate, default: a random uuid4
ACINT_TOKEN=keep_this_secret
The proxy path for the service, default: /
ACINT_PROXY_PATH=/
The environment to use: dev
| prod
, default: prod
ACINT_ENV=prod
The service is built to be easily integrated into smnrp
.
The following example docker-compose
and .env
shows how to run acint
beside smnrp
.
services:
ws:
image: ethnexus/smnrp
...
depends_on:
- acint
acint:
image: ethnexus/acint
volumes:
- ./.acint:/do
env_file: .env
restart: unless-stopped
...
SMNRP_UPSTREAMS=acint!acint:80
SMNRP_LOCATIONS=/acint/!http://acint/
...
ACINT_ALLOWED_ACTIONS=.deploy
ACINT_TOKEN=keep_this_secret
ACINT_PROXY_PATH=/
...
The acint
web service can be triggered from a git workflow using the fjogeleit/http-request-action@v1
action.
Here is an example workflow that triggers on any new tag (after git tag -a v1.0.0
, git push --tags
):
name: Deploy Application
on:
push:
tags:
- "*"
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Trigger deployment
id: deployTrigger
uses: fjogeleit/http-request-action@v1
with:
url: ${{ secrets.ACINT_URL }}
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
data: '{ "action": "${{ secrets.ACINT_ACTION }}", "token": "${{ secrets.ACINT_TOKEN }}" }'
Please make sure you have set up the following secrets in the git repository:
ACINT_URL
: The url to the acint service (e.g.https://domain.com/acint/
)ACINT_ACTION
: The action to trigger (must be listed inACINT_ALLOWED_ACTIONS
)ACINT_TOKEN
: The token used to authenticate the request (must be identical toACINT_TOKEN
)
The following script can be added to a crontab to be run every minute. It will run the redeploy command make redeploy
if
the DEPLOY_TRIGGER
file exists. The same principle can be adapted for any action you want to trigger from "outside".
#!/usr/bin/env bash
PROJECT_DIR="/path/to/project"
DEPLOY_TRIGGER="${PROJECT_DIR}/.acint/.deploy"
if [ -f ${DEPLOY_TRIGGER} ]; then
echo "##############"
echo `date`
rm -f ${DEPLOY_TRIGGER}
cd ${PROJECT_DIR}
make redeploy
fi
The following entry can be added to the repository's owners crontab:
* * * * * (sudo /path/to/project/scripts/redeployIfNeeded.sh 2>&1) >> /path/to/project/logs/redeploy.log
You can use curl
to test acint
:
curl -i \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-X POST --data '{ "action": "<ACINT_ACTION>", "token": "<ACINT_TOKEN>" }' \
https://<host>/acint/