112 lines
4.0 KiB
YAML
112 lines
4.0 KiB
YAML
name: Renovate PR Deployment
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
types: [closed]
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
deploy:
|
|
if: |
|
|
github.event.pull_request.merged == true &&
|
|
github.event.pull_request.user.login == 'renovate-bot'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Detect Renovate update type
|
|
id: detect-update
|
|
env:
|
|
PR_BODY: ${{ github.event.pull_request.body }}
|
|
run: |
|
|
echo "PR body: $PR_BODY"
|
|
|
|
if echo "$PR_BODY" | grep -qE 'Update Type: (patch|minor|major|digest)'; then
|
|
echo "update=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "update=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Stop if update not patch/minor/major/digest
|
|
if: steps.detect-update.outputs.update != 'true'
|
|
run: |
|
|
echo "::warning::This PR does not involve patch/minor/major/digest update. Skipping deployment."
|
|
exit 0
|
|
|
|
- name: Get changed services from docker-compose.yml
|
|
id: services
|
|
run: |
|
|
git fetch origin ${{ github.event.pull_request.base.ref }}
|
|
git show origin/main:docker-compose.yml > docker-compose-main.yml || touch docker-compose-main.yml
|
|
cp docker-compose.yml docker-compose-head.yml
|
|
|
|
echo "Getting services from main and ${{ github.ref_name }}"
|
|
yq '.services | keys | .[]' docker-compose-main.yml | sort > services_main.txt
|
|
yq '.services | keys | .[]' docker-compose-head.yml | sort > services_head.txt
|
|
|
|
echo "Creating list of modified services..."
|
|
touch service_changes.txt
|
|
|
|
comm -13 services_main.txt services_head.txt | while read service; do
|
|
echo "$service: added" >> service_changes.txt
|
|
done
|
|
|
|
comm -12 services_main.txt services_head.txt | while read service; do
|
|
yq ".services[\"$service\"]" docker-compose-main.yml > tmp_main.yml
|
|
yq ".services[\"$service\"]" docker-compose-head.yml > tmp_head.yml
|
|
if ! diff -q tmp_main.yml tmp_head.yml > /dev/null; then
|
|
echo "$service: modified" >> service_changes.txt
|
|
fi
|
|
done
|
|
|
|
echo "Detected service changes:"
|
|
cat service_changes.txt
|
|
|
|
mod_svcs=$(cut -d':' -f1 service_changes.txt | sort | uniq)
|
|
echo "docker_svc_list<<EOF" >> "$GITHUB_OUTPUT"
|
|
echo "$mod_svcs" >> "$GITHUB_OUTPUT"
|
|
echo "EOF" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: List of Services for (Re)Deployment
|
|
run: |
|
|
echo -e "${{ steps.services.outputs.docker_svc_list }}"
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@master
|
|
with:
|
|
gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}'
|
|
gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}'
|
|
notification_title: 'GITEA: [RENOVATE] Docker Compose Deployment @ Rinoa'
|
|
notification_message: 'Starting Docker Compose run...'
|
|
|
|
- name: Docker Compose Deployment
|
|
uses: hoverkraft-tech/compose-action@v2.2.0
|
|
env:
|
|
DOCKER_HOST: tcp://dockerproxy:2375
|
|
with:
|
|
services: |
|
|
${{ steps.services.outputs.docker_svc_list }}
|
|
up-flags: -d --remove-orphans --pull always
|
|
compose-flags: --profile rinoa-apps
|
|
|
|
- name: Docker Compose Healthcheck
|
|
id: health
|
|
uses: jaracogmbh/docker-compose-health-check-action@v1.0.0
|
|
with:
|
|
max-retries: 30
|
|
retry-interval: 10
|
|
compose-file: "docker-compose.yml"
|
|
skip-exited: "true"
|
|
skip-no-healthcheck: "true"
|
|
|
|
- name: Gotify Notification
|
|
uses: eikendev/gotify-action@master
|
|
with:
|
|
gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}'
|
|
gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}'
|
|
notification_title: 'GITEA: [RENOVATE] Docker Compose Deployment @ Rinoa'
|
|
notification_message: 'Deployment completed successfully.'
|