This commit is contained in:
2025-01-19 10:14:22 -05:00
parent 46ed74e052
commit 96e01309f5
@@ -30,18 +30,16 @@ jobs:
id: check-opened-pr-step id: check-opened-pr-step
continue-on-error: true continue-on-error: true
run: | run: |
echo "Adding tea login"
tea login add --name gitea-rinoa --url ${{ secrets.RINOA_GITEA_URL }} --user gitea-sonarqube-bot --password "${{ secrets.BOT_GITEA_PASSWORD }}" --token ${{ secrets.BOT_GITEA_TOKEN }} tea login add --name gitea-rinoa --url ${{ secrets.RINOA_GITEA_URL }} --user gitea-sonarqube-bot --password "${{ secrets.BOT_GITEA_PASSWORD }}" --token ${{ secrets.BOT_GITEA_TOKEN }}
tea login default gitea-rinoa tea login default gitea-rinoa
pr_exists=$(tea pr list --repo ${{ github.repository }} --state open --fields index,title,head | egrep ${{ github.ref_name }} | tail -1 | wc -l) pr_exists=$(tea pr list --repo ${{ github.repository }} --state open --fields index,title,head | egrep ${{ github.ref_name }} | tail -1 | wc -l)
echo ${pr_exists}
echo "exists=$pr_exists" >> $GITHUB_OUTPUT echo "exists=$pr_exists" >> $GITHUB_OUTPUT
- name: Create PR - name: Create PR
if: ${{ steps.check-opened-pr-step.outputs.exists == '0' }} if: ${{ steps.check-opened-pr-step.outputs.exists == '0' }}
run: | run: |
tea pr ls --repo ${{ github.repository }} --state all --fields index,title,head --output csv | egrep -v 'index' | head -2 | awk -F, '{print $1}' | sed -e 's|"||g' tea pr ls --repo ${{ github.repository }} --state all --fields index,title,head --output csv | head -2 | tail -1 | awk -F, '{print $1}' | sed -e 's|"||g'
pr_index_old=$(tea pr ls --repo ${{ github.repository }} --state all --fields index,title,head --output csv | egrep -v 'index' | head | awk -F, '{print $1}' | sed -e 's|"||g') pr_index_old=$(tea pr ls --repo ${{ github.repository }} --state all --fields index,title,head --output csv | head -2 | tail -1 | awk -F, '{print $1}' | sed -e 's|"||g')'
echo "${pr_index_old}"
expr ${pr_index_old} + 1
pr_index_new=$(expr ${pr_index_old} + 1) pr_index_new=$(expr ${pr_index_old} + 1)
tea pr c -r ${{ github.repository }} -t "Automated PR for ${{ github.ref_name }} - ${pr_index_new}" -d "Automatically created PR for branch: ${{ github.ref_name }}" -a ${{ github.actor }} tea pr c -r ${{ github.repository }} -t "Automated PR for ${{ github.ref_name }} - ${pr_index_new}" -d "Automatically created PR for branch: ${{ github.ref_name }}" -a ${{ github.actor }}
docker-compose-ansible-lints: docker-compose-ansible-lints:
@@ -54,23 +52,33 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 1
# Cache Ansible Galaxy Collections
- name: Cache Ansible Galaxy Collections - name: Cache Ansible Galaxy Collections
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: ./ansible/collections path: ansible/collections
key: ${{ runner.os }}-ansible-${{ hashFiles('./ansible/collections/requirements.yml') }} key: ${{ runner.os }}-ansible-${{ hashFiles('./ansible/collections/requirements.yml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-ansible- ${{ runner.os }}-ansible-
# Install Ansible
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Ansible - name: Install Ansible
run: | run: |
python3 -m pip install --upgrade pip python3 -m pip install --upgrade pip
pip3 install ansible pip3 install ansible
- name: Install Vault - name: Install Vault
uses: cpanato/vault-installer@main uses: cpanato/vault-installer@main
# Install Galaxy Collections
- name: Install Galaxy Collections - name: Install Galaxy Collections
if: steps.cache-ansible-galaxy-collections.outputs.cache-hit != 'true' if: steps.cache-ansible-galaxy-collections.outputs.cache-hit != 'true'
run: | run: |
ansible-galaxy collection install -r ansible/collections/requirements.yml -p ansible/collections ansible-galaxy collection install -r ansible/collections/requirements.yml -p ansible/collections
# Run Docker Config Deployment
- name: Docker Config Deployment - name: Docker Config Deployment
id: docker-config-deploy id: docker-config-deploy
uses: arillso/action.playbook@0.0.8 uses: arillso/action.playbook@0.0.8
@@ -79,19 +87,22 @@ jobs:
diff: true diff: true
galaxy_collections_path: ansible/collections galaxy_collections_path: ansible/collections
galaxy_requirements_file: ansible/collections/requirements.yml galaxy_requirements_file: ansible/collections/requirements.yml
inventory: ansible/inventory/hosts.yml inventory: ansible/ansible-inventory.yml
playbook: ansible/docker_config_deploy.yml playbook: ansible/docker_config_deploy.yml
private_key: ${{ secrets.RINOA_ANSIBLE_PRIVATE_KEY }} private_key: ${{ secrets.RINOA_ANSIBLE_PRIVATE_KEY }}
vault_password: ${{ secrets.ANSIBLE_VAULT_PASSWORD }} vault_password: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
verbose: 1 verbose: 1
# Generate .env File
- name: Generate .env file for Docker Compose Dry Run - name: Generate .env file for Docker Compose Dry Run
run: | run: |
vault kv get -format=json rinoa-docker/env | jq -r '.data.data' | jq -r 'keys[] as $k | "\($k)='\''\(.[$k])'\''"' > .env vault kv get -format=json rinoa-docker/env | jq -r '.data.data' | jq -r 'keys[] as $k | "\($k)='\''\(.[$k])'\''"' > .env
# Cache .env File
- name: Cache .env Files - name: Cache .env Files
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: .env path: .env
key: ${{ runner.os }}-env-${{ hashFiles('docker-compose.yml') }} key: ${{ runner.os }}-env-${{ hashFiles('docker-compose.yml') }}
# Docker Compose Dry Run
- name: Docker Compose Dry Run - name: Docker Compose Dry Run
uses: yu-ichiro/spin-up-docker-compose-action@v1 uses: yu-ichiro/spin-up-docker-compose-action@v1
with: with: