Skip to content

Commit

Permalink
create action update_compose_dbs
Browse files Browse the repository at this point in the history
  • Loading branch information
rafsaf committed Oct 15, 2023
1 parent 35fd425 commit c7f38f1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
37 changes: 37 additions & 0 deletions .github/workflows/update_compose_dbs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: update-compose-dbs
on:
workflow_dispatch:
schedule:
- cron: "12 6,18 * * *"
jobs:
update_compose_dbs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12.0"

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies and actiavte virtualenv
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Check update
run: |
./scripts/gh_update_dbs_with_pr.sh
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ acceptance_tests_arm64:
docker compose -f docker/docker-compose.tests.yml run --rm backuper_acceptance_test_arm64

update_compose_db_file:
python backuper/tools/compose_file_generator.py > docker/docker-compose.dbs.yml
poetry run python backuper/tools/compose_file_generator.py > docker/docker-compose.dbs.yml
20 changes: 20 additions & 0 deletions scripts/gh_update_dbs_with_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DB_COMPOSE_FILE="$SCRIPT_DIR/../docker/docker-compose.dbs.yml"

cd $SCRIPT_DIR/../
make update_compose_db_file
DIFF=$(git diff $DB_COMPOSE_FILE)
if [ "$DIFF" = "" ]
then
echo "no changes detected"
else
echo "file changed"
timestamp=$(date +%s)
branch="update-docker-compose-dbs-$timestamp"
msg="update docker-compose.dbs.yml file"
git branch $branch
git commit -am $msg
git push -u origin $branch
gh pr create -B main -H $branch --title $msg --body 'Created by Github action'
fi

0 comments on commit c7f38f1

Please sign in to comment.