From fd2fd5eb4ba5e749b4da3ab2ced9ac115dbc7366 Mon Sep 17 00:00:00 2001 From: hogweed1 Date: Fri, 21 Nov 2025 01:09:08 +1000 Subject: [PATCH] ceph-metrics --- .gitea/workflows/act.yaml | 82 ++++++++++++--------------------------- playbooker.sh | 27 +++++++++++++ 2 files changed, 51 insertions(+), 58 deletions(-) create mode 100644 playbooker.sh diff --git a/.gitea/workflows/act.yaml b/.gitea/workflows/act.yaml index 6ba493a..d9f08b7 100644 --- a/.gitea/workflows/act.yaml +++ b/.gitea/workflows/act.yaml @@ -15,68 +15,34 @@ jobs: cd /usr/share/ansible-repo/ git pull shell: bash - - # - name: Checkout repository manually using bash - # run: | - # # Ensure the workspace directory is clean and navigate into it - # # GITHUB_WORKSPACE is an environment variable set by the runner - # cd $GITHUB_WORKSPACE +# - name: common-setup-just-created +# run: | +# #!/bin/bash - # # Authenticate using the GITEA_TOKEN (managed by Gitea Actions) - # # GITHUB_SERVER_URL and GITHUB_REPOSITORY are also standard env vars - # git clone --depth=1 https://${{ gitea.token }}@${GITHUB_SERVER_URL#*://}/${GITHUB_REPOSITORY}.git . - - # # Optional: checkout a specific pull request head if it's a PR event - # # Note: Gitea uses refs/pull/:prNumber/head instead of merge commits for PRs - # if [ "${{ github.event_name }}" = "pull_request" ]; then - # git checkout ${{ github.event.pull_request.head.sha }} - # fi +# # Get the list of changed files +# CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD) - # - name: Check system info using bash - # run: | - # echo "Running on the host machine" - # uname -a - # which bash - # bash --version +# # Initialize an array for playbooks to run +# PLAYBOOKS_TO_RUN=() - # - name: List files in the workspace - # run: ls -lsa +# # Check for changes in specific directories and add corresponding playbooks +# if echo "$CHANGED_FILES" | grep -q "roles/webserver/"; then +# PLAYBOOKS_TO_RUN+=("playbooks/webserver.yml") +# fi - # - name: Run a simple bash script - # run: | - # echo "Hello from Gitea Actions!" - # mkdir -p my_output - # echo "This was created by a workflow running on the host." > my_output/output.txt - # shell: bash - - # - name: Checkout repository - # uses: actions/checkout@v3 +# if echo "$CHANGED_FILES" | grep -q "roles/database/"; then +# PLAYBOOKS_TO_RUN+=("playbooks/database.yml") +# fi - # - name: Check system info using bash - # run: | - # echo "Running on the host machine" - # uname -a - # which bash - # bash --version +# # Run the identified playbooks +# if [ ${#PLAYBOOKS_TO_RUN[@]} -gt 0 ]; then +# for playbook in "${PLAYBOOKS_TO_RUN[@]}"; do +# echo "Running playbook: $playbook" +# ansible-playbook "$playbook" -i inventory.ini +# done +# else +# echo "No relevant playbooks modified. Skipping Ansible run." +# fi +# shell: bash - # - name: List files in the workspace - # run: ls -lsa - - # - name: Run a simple bash script - # run: | - # echo "Hello from Gitea Actions!" - # mkdir -p my_output - # echo "This was created by a workflow running on the host." > my_output/output.txt - # shell: bash - # - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - # - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - # - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - # - name: Check out repository code - # uses: actions/checkout@v4 - # - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - # - run: echo "🖥️ The workflow is now ready to test your code on the runner." - # - name: List files in the repository - # run: | - # ls ${{ gitea.workspace }} - # - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file diff --git a/playbooker.sh b/playbooker.sh new file mode 100644 index 0000000..ea72277 --- /dev/null +++ b/playbooker.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Get the list of changed files +CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD) + +# Initialize an array for playbooks to run +PLAYBOOKS_TO_RUN=() + +# Check for changes in specific directories and add corresponding playbooks +if echo "$CHANGED_FILES" | grep -q "roles/webserver/"; then +PLAYBOOKS_TO_RUN+=("playbooks/webserver.yml") +fi + +if echo "$CHANGED_FILES" | grep -q "roles/database/"; then +PLAYBOOKS_TO_RUN+=("playbooks/database.yml") +fi + +# Run the identified playbooks +if [ ${#PLAYBOOKS_TO_RUN[@]} -gt 0 ]; then +for playbook in "${PLAYBOOKS_TO_RUN[@]}"; do + echo "Running playbook: $playbook" + ansible-playbook "$playbook" -i inventory.ini +done +else +echo "No relevant playbooks modified. Skipping Ansible run." +fi +shell: bash \ No newline at end of file