Adding caching steps.
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
name: Gitea Branch PR, Cloudflare DNS, README generation, & Docker Deployment
|
name: Gitea Branch PR, Cloudflare DNS, README generation, & Ansible/Docker Deployment
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches-ignore:
|
branches-ignore:
|
||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- '**.yml'
|
- '**.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-and-create-pr:
|
check-and-create-pr:
|
||||||
name: Check and Create PR
|
name: Check and Create PR
|
||||||
@@ -12,6 +13,13 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
- name: Cache tea CLI
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.tea
|
||||||
|
key: tea-${{ runner.os }}-${{ hashFiles('workflow-config.yml') }}
|
||||||
- name: Install tea
|
- name: Install tea
|
||||||
uses: supplypike/setup-bin@v4
|
uses: supplypike/setup-bin@v4
|
||||||
with:
|
with:
|
||||||
@@ -22,21 +30,16 @@ jobs:
|
|||||||
id: check-opened-pr-step
|
id: check-opened-pr-step
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
echo "Logging into Gitea..."
|
|
||||||
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 }}
|
||||||
echo "Setting default login to gitea-rinoa..."
|
|
||||||
tea login default gitea-rinoa
|
tea login default gitea-rinoa
|
||||||
echo "Checking for existing PRs..."
|
|
||||||
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 ${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: |
|
||||||
echo "Creating PR for branch: ${{ github.ref_name }}"
|
|
||||||
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')'
|
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')'
|
||||||
pr_index_new=$(expr ${pr_index_old} + 1)
|
pr_index_new=$(expr ${pr_index_old} + 1)
|
||||||
echo "New PR index: ${pr_index_new}"
|
|
||||||
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:
|
||||||
name: Docker Compose & Ansible Lints
|
name: Docker Compose & Ansible Lints
|
||||||
@@ -48,30 +51,34 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install jq
|
|
||||||
uses: dcarbone/install-jq-action@v3.0.1
|
|
||||||
- name: Install Vault
|
|
||||||
uses: cpanato/vault-installer@main
|
|
||||||
with:
|
with:
|
||||||
vault-release: '1.18.3'
|
fetch-depth: 1
|
||||||
- name: Install hvac (Python library for HashiCorp Vault)
|
- name: Cache Ansible Galaxy Collections
|
||||||
uses: insightsengineering/pip-action@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
packages: hvac
|
path: ansible/collections
|
||||||
- name: Ansible Playbook Dry Run
|
key: ${{ runner.os }}-ansible-${{ hashFiles('ansible/collections/requirements.yml') }}
|
||||||
uses: arillso/action.playbook@0.0.8
|
restore-keys: |
|
||||||
|
${{ runner.os }}-ansible-
|
||||||
|
- name: Install Ansible Galaxy Collections
|
||||||
|
run: ansible-galaxy collection install -r ansible/collections/requirements.yml -p ansible/collections
|
||||||
|
- name: Cache Python Dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
galaxy_collections_path: ansible/collections
|
path: ~/.cache/pip
|
||||||
galaxy_requirements_file: ansible/collections/requirements.yml
|
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
|
||||||
inventory: ansible/ansible-inventory
|
restore-keys: |
|
||||||
playbook: ansible/docker_config_deploy.yml
|
${{ runner.os }}-pip-
|
||||||
check: true
|
- name: Install Python Dependencies
|
||||||
diff: true
|
run: pip install -r requirements.txt
|
||||||
vault_password: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
|
|
||||||
verbose: 1
|
|
||||||
- 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
|
||||||
|
- name: Cache .env Files
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .env
|
||||||
|
key: ${{ runner.os }}-env-${{ hashFiles('docker-compose.yml') }}
|
||||||
- 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:
|
||||||
@@ -89,25 +96,33 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Install jq
|
with:
|
||||||
uses: dcarbone/install-jq-action@v3.0.1
|
fetch-depth: 1
|
||||||
- name: Install yq
|
- name: Cache flarectl CLI
|
||||||
uses: dcarbone/install-yq-action@v1
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.flarectl
|
||||||
|
key: flarectl-${{ runner.os }}-${{ hashFiles('workflow-config.yml') }}
|
||||||
- name: Install flarectl
|
- name: Install flarectl
|
||||||
uses: supplypike/setup-bin@v4
|
uses: supplypike/setup-bin@v4
|
||||||
with:
|
with:
|
||||||
uri: 'https://github.com/cloudflare/cloudflare-go/releases/download/v0.113.0/flarectl_0.113.0_linux_amd64.tar.gz'
|
uri: 'https://github.com/cloudflare/cloudflare-go/releases/download/v0.113.0/flarectl_0.113.0_linux_amd64.tar.gz'
|
||||||
name: 'flarectl'
|
name: 'flarectl'
|
||||||
version: '0.113.0'
|
version: '0.113.0'
|
||||||
|
- name: Cache Subdomain Files
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
compose_subdomains.txt
|
||||||
|
cloudflare_subdomains.txt
|
||||||
|
key: ${{ runner.os }}-subdomains-${{ hashFiles('docker-compose.yml') }}
|
||||||
- name: Grab Subdomains from Docker Compose & Cloudflare
|
- name: Grab Subdomains from Docker Compose & Cloudflare
|
||||||
id: grab-subdomains
|
id: grab-subdomains
|
||||||
env:
|
env:
|
||||||
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
|
||||||
CF_API_EMAIL: ${{ secrets.CF_API_EMAIL }}
|
CF_API_EMAIL: ${{ secrets.CF_API_EMAIL }}
|
||||||
run: |
|
run: |
|
||||||
echo "Grabbing subdomains from docker-compose.yml..."
|
|
||||||
yq '.services[].labels.swag_url' docker-compose.yml | egrep -v 'null' | sed -e 's|"||g' | awk -F'.' '{print $1}' | sort > compose_subdomains.txt
|
yq '.services[].labels.swag_url' docker-compose.yml | egrep -v 'null' | sed -e 's|"||g' | awk -F'.' '{print $1}' | sort > compose_subdomains.txt
|
||||||
echo "Grabbing subdomains from Cloudflare..."
|
|
||||||
flarectl --json dns list --zone "trez.wtf" --type=CNAME --content "trez.wtf" | jq '.[].Name' | sed -e 's|"||g' | awk -F"." '{print $1}' | sort > cloudflare_subdomains.txt
|
flarectl --json dns list --zone "trez.wtf" --type=CNAME --content "trez.wtf" | jq '.[].Name' | sed -e 's|"||g' | awk -F"." '{print $1}' | sort > cloudflare_subdomains.txt
|
||||||
- name: Compare Subdomains
|
- name: Compare Subdomains
|
||||||
id: compare-subdomains
|
id: compare-subdomains
|
||||||
|
|||||||
Reference in New Issue
Block a user