Fixes for Immich; testing out new step in deployment pipeline.

This commit is contained in:
2025-01-31 07:47:22 -05:00
parent 42a0928b7f
commit a94057d1ae
2 changed files with 211 additions and 211 deletions
+205 -205
View File
@@ -60,6 +60,18 @@ jobs:
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-
- name: Detect modified services
id: detect-modified-services
run: |
git diff --name-only HEAD^ HEAD | grep docker-compose.yml > /dev/null
if [ $? -eq 0 ]; then
modified_services=$(git diff HEAD^ HEAD -- docker-compose.yml | grep -E '^\+[[:space:]]+[a-zA-Z0-9_-]+:' | sed -E 's/^\+[[:space:]]+([a-zA-Z0-9_-]+):.*/\1/')
echo "Modified services: $modified_services"
echo "modified_services=$modified_services" >> $GITHUB_OUTPUT
else
echo "No changes in docker-compose.yml"
echo "modified_services=" >> $GITHUB_OUTPUT
fi
- name: Install Ansible - name: Install Ansible
uses: alex-oleshkevich/setup-ansible@v1.0.1 uses: alex-oleshkevich/setup-ansible@v1.0.1
with: with:
@@ -111,208 +123,196 @@ jobs:
gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}' gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}'
notification_title: 'GITEA: Docker Compose Dry Run @ Rinoa' notification_title: 'GITEA: Docker Compose Dry Run @ Rinoa'
notification_message: 'Docker Compose dry run completed successfully.' notification_message: 'Docker Compose dry run completed successfully.'
cloudflare-dns-setup: # cloudflare-dns-setup:
name: Cloudflare DNS Setup # name: Cloudflare DNS Setup
needs: [docker-compose-ansible-lints] # needs: [docker-compose-ansible-lints]
runs-on: ubuntu-latest # runs-on: ubuntu-latest
steps: # steps:
- name: Checkout # - name: Checkout
uses: actions/checkout@v4 # uses: actions/checkout@v4
with: # with:
fetch-depth: 1 # fetch-depth: 1
- name: Cache flarectl CLI # - name: Cache flarectl CLI
uses: actions/cache@v4 # uses: actions/cache@v4
with: # with:
path: ~/.flarectl # path: ~/.flarectl
key: flarectl-${{ runner.os }}-${{ hashFiles('workflow-config.yml') }} # 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 # - name: Cache Subdomain Files
uses: actions/cache@v4 # uses: actions/cache@v4
with: # with:
path: | # path: |
compose_subdomains.txt # compose_subdomains.txt
cloudflare_subdomains.txt # cloudflare_subdomains.txt
key: ${{ runner.os }}-subdomains-${{ hashFiles('docker-compose.yml') }} # 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: |
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
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: Gotify Notification # - name: Gotify Notification
uses: eikendev/gotify-action@master # uses: eikendev/gotify-action@master
with: # with:
gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}' # gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}'
gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}' # gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}'
notification_title: 'GITEA: Cloudflare Setup @ Rinoa' # notification_title: 'GITEA: Cloudflare Setup @ Rinoa'
notification_message: 'Starting Cloudflare setup' # notification_message: 'Starting Cloudflare setup'
- name: Compare Subdomains # - name: Compare Subdomains
id: compare-subdomains # id: compare-subdomains
uses: LouisBrunner/diff-action@v2.2.0 # uses: LouisBrunner/diff-action@v2.2.0
with: # with:
old: compose_subdomains.txt # old: compose_subdomains.txt
new: cloudflare_subdomains.txt # new: cloudflare_subdomains.txt
mode: addition # mode: addition
tolerance: mixed-better # tolerance: mixed-better
output: domain_compare.txt # output: domain_compare.txt
- name: Create Subdomains # - name: Create Subdomains
if: steps.compare-subdomains.outputs.output != '' # if: steps.compare-subdomains.outputs.output != ''
continue-on-error: true # continue-on-error: true
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: |
cat domain_compare.txt | egrep '^-[a-z]' | sed -e 's|-||g' | while read -r subdomain; do # cat domain_compare.txt | egrep '^-[a-z]' | sed -e 's|-||g' | while read -r subdomain; do
echo "Creating $subdomain.trez.wtf..." # echo "Creating $subdomain.trez.wtf..."
flarectl dns create --zone "trez.wtf" --name "${subdomain}" --type=CNAME --content "trez.wtf" --proxy true # flarectl dns create --zone "trez.wtf" --name "${subdomain}" --type=CNAME --content "trez.wtf" --proxy true
done # done
- name: Gotify Notification # - name: Gotify Notification
uses: eikendev/gotify-action@master # uses: eikendev/gotify-action@master
with: # with:
gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}' # gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}'
gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}' # gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}'
notification_title: 'GITEA: Cloudflare Setup @ Rinoa' # notification_title: 'GITEA: Cloudflare Setup @ Rinoa'
notification_message: 'Cloudflare DNS setup completed successfully.' # notification_message: 'Cloudflare DNS setup completed successfully.'
regenerate-readme: # regenerate-readme:
name: Update README # name: Update README
runs-on: ubuntu-latest # runs-on: ubuntu-latest
needs: [cloudflare-dns-setup] # needs: [cloudflare-dns-setup]
outputs: # outputs:
pr-pushed: ${{ steps.commit-readme.outputs.pushed }} # pr-pushed: ${{ steps.commit-readme.outputs.pushed }}
steps: # steps:
- name: Checkout # - name: Checkout
uses: actions/checkout@v4 # uses: actions/checkout@v4
- name: Install yq # - name: Install yq
uses: dcarbone/install-yq-action@v1 # uses: dcarbone/install-yq-action@v1
- name: Generate service list # - name: Generate service list
run: | # run: |
yq '.services | to_entries | map({"service": .key, "image": .value.image})' docker-compose.yml > services.yml # yq '.services | to_entries | map({"service": .key, "image": .value.image})' docker-compose.yml > services.yml
- name: Generate Markdown Table # - name: Generate Markdown Table
uses: gazab/create-markdown-table@v1 # uses: gazab/create-markdown-table@v1
id: service-table # id: service-table
with: # with:
file: ./services.yml # file: ./services.yml
- name: Regenerate README # - name: Regenerate README
run: | # run: |
echo "# List of Services" > README.md # echo "# List of Services" > README.md
echo -e "\n\n" >> README.md # echo -e "\n\n" >> README.md
echo "${{ steps.service-table.outputs.table }}" >> README.md # echo "${{ steps.service-table.outputs.table }}" >> README.md
- name: Add/Commit README.md # - name: Add/Commit README.md
id: commit-readme # id: commit-readme
uses: EndBug/add-and-commit@v9 # uses: EndBug/add-and-commit@v9
with: # with:
message: "chore: Update README" # message: "chore: Update README"
add: "README.md" # add: "README.md"
pr-merge: # pr-merge:
name: PR Merge # name: PR Merge
needs: [regenerate-readme] # needs: [regenerate-readme]
runs-on: ubuntu-latest # runs-on: ubuntu-latest
steps: # steps:
- name: Checkout # - name: Checkout
uses: actions/checkout@v4 # uses: actions/checkout@v4
- name: Install tea # - name: Install tea
uses: supplypike/setup-bin@v4 # uses: supplypike/setup-bin@v4
with: # with:
uri: 'https://gitea.com/gitea/tea/releases/download/v0.9.2/tea-0.9.2-linux-amd64' # uri: 'https://gitea.com/gitea/tea/releases/download/v0.9.2/tea-0.9.2-linux-amd64'
name: 'tea' # name: 'tea'
version: '0.9.2' # version: '0.9.2'
- name: PR Merge # - name: PR Merge
id: pr_merge # id: pr_merge
run: | # run: |
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
echo "Merging PR..." # echo "Merging PR..."
pr_index=$(tea pr ls --repo ${{ github.repository }} --state open --fields index,title,head,state --output csv | egrep ${{ github.ref_name }} | awk -F"," '{print $1}' | sed -e 's|"||g') # pr_index=$(tea pr ls --repo ${{ github.repository }} --state open --fields index,title,head,state --output csv | egrep ${{ github.ref_name }} | awk -F"," '{print $1}' | sed -e 's|"||g')
tea pr m --repo ${{ github.repository }} --title "Auto Merge of PR ${pr_index} - ${{ github.ref_name }}" --message "Merged by ${{ github.actor }}" ${pr_index} # tea pr m --repo ${{ github.repository }} --title "Auto Merge of PR ${pr_index} - ${{ github.ref_name }}" --message "Merged by ${{ github.actor }}" ${pr_index}
echo "pr_index=${pr_index}" >> $GITHUB_OUTPUT # echo "pr_index=${pr_index}" >> $GITHUB_OUTPUT
- name: Gotify Notification # - name: Gotify Notification
uses: eikendev/gotify-action@master # uses: eikendev/gotify-action@master
with: # with:
gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}' # gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}'
gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}' # gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}'
notification_title: 'GITEA: PR Merge Successful' # notification_title: 'GITEA: PR Merge Successful'
notification_message: 'PR #${{ steps.pr_merge.outputs.pr_index }} merged.' # notification_message: 'PR #${{ steps.pr_merge.outputs.pr_index }} merged.'
ansible-config-docker-compose-deploy: # ansible-config-docker-compose-deploy:
name: Deploy via Ansible & Docker Compose # name: Deploy via Ansible & Docker Compose
runs-on: ubuntu-latest # runs-on: ubuntu-latest
needs: [pr-merge] # needs: [pr-merge]
env: # env:
VAULT_ADDR: ${{ secrets.RINOA_VAULT_ADDR }} # VAULT_ADDR: ${{ secrets.RINOA_VAULT_ADDR }}
VAULT_TOKEN: ${{ secrets.VAULT_GITEA_TOKEN }} # VAULT_TOKEN: ${{ secrets.VAULT_GITEA_TOKEN }}
DOCKER_HOST: tcp://dockerproxy:2375 # DOCKER_HOST: tcp://dockerproxy:2375
steps: # steps:
- name: Checkout # - name: Checkout
uses: actions/checkout@v4 # uses: actions/checkout@v4
with: # with:
ref: main # ref: main
- name: Cache Vault install # - name: Cache Vault install
id: cache-vault # id: cache-vault
uses: actions/cache@v4 # uses: actions/cache@v4
with: # with:
path: /opt/hostedtoolcache/vault/1.18.0/x64 # path: /opt/hostedtoolcache/vault/1.18.0/x64
key: vault-${{ runner.os }}-1.18.0 # key: vault-${{ runner.os }}-1.18.0
- name: Install Ansible # - name: Install Ansible
uses: alex-oleshkevich/setup-ansible@v1.0.1 # uses: alex-oleshkevich/setup-ansible@v1.0.1
with: # with:
version: "11.0.0" # version: "11.0.0"
- name: Install Vault # - name: Install Vault
uses: cpanato/vault-installer@main # uses: cpanato/vault-installer@main
- name: Install hvac # - name: Install hvac
run: pip install hvac # run: pip install hvac
- name: Deploy Docker Configs via Ansible # - name: Deploy Docker Configs via Ansible
uses: dawidd6/action-ansible-playbook@v2 # uses: dawidd6/action-ansible-playbook@v2
with: # with:
directory: ansible/ # directory: ansible/
playbook: docker_config_deploy.yml # playbook: docker_config_deploy.yml
key: ${{secrets.RINOA_ANSIBLE_PRIVATE_KEY}} # key: ${{secrets.RINOA_ANSIBLE_PRIVATE_KEY}}
options: | # options: |
--inventory inventory/hosts.yml # --inventory inventory/hosts.yml
requirements: collections/requirements.yml # requirements: collections/requirements.yml
vault_password: ${{ secrets.ANSIBLE_VAULT_PASSWORD }} # vault_password: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
- name: Gotify Notification # - name: Gotify Notification
uses: eikendev/gotify-action@master # uses: eikendev/gotify-action@master
with: # with:
gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}' # gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}'
gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}' # gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}'
notification_title: 'GITEA: Ansible Config Deployment @ Rinoa' # notification_title: 'GITEA: Ansible Config Deployment @ Rinoa'
notification_message: 'Deployment completed successfully.' # notification_message: 'Deployment completed successfully.'
- name: Generate .env file for deployment # - name: Generate .env file for deployment
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: Detect modified services # - name: Docker Compose Deployment
id: detect-modified-services # if: ${{ steps.detect-modified-services.outputs.modified_services != '' }}
run: | # continue-on-error: true
git diff --name-only HEAD^ HEAD | grep docker-compose.yml > /dev/null # uses: keatonLiu/docker-compose-remote-action@v1.2
if [ $? -eq 0 ]; then # with:
modified_services=$(git diff HEAD^ HEAD -- docker-compose.yml | grep -E '^\+[[:space:]]+[a-zA-Z0-9_-]+:' | sed -E 's/^\+[[:space:]]+([a-zA-Z0-9_-]+):.*/\1/') # docker_compose_file: docker-compose.yml
echo "Modified services: $modified_services" # docker_args: -d --remove-orphans --pull missing --parallel -1
echo "modified_services=$modified_services" >> $GITHUB_OUTPUT # ssh_user: gitea-deploy
else # ssh_host: 192.168.1.254
echo "No changes in docker-compose.yml" # ssh_host_public_key: ${{ secrets.RINOA_GITEA_PUBLIC_SSH_KEY }}
echo "modified_services=" >> $GITHUB_OUTPUT # ssh_private_key: ${{ secrets.RINOA_GITEA_PRIVATE_SSH_KEY }}
fi # - name: Gotify Notification
- name: Docker Compose Deployment # uses: eikendev/gotify-action@master
if: ${{ steps.detect-modified-services.outputs.modified_services != '' }} # with:
continue-on-error: true # gotify_api_base: '${{ secrets.RINOA_GOTIFY_URL }}'
uses: keatonLiu/docker-compose-remote-action@v1.2 # gotify_app_token: '${{ secrets.RINOA_RUNNER_GOTIFY_TOKEN }}'
with: # notification_title: 'GITEA: Docker Compose Deployment @ Rinoa'
docker_compose_file: docker-compose.yml # notification_message: 'Deployment completed successfully.'
docker_args: -d --remove-orphans --pull missing --parallel -1
ssh_user: gitea-deploy
ssh_host: 192.168.1.254
ssh_host_public_key: ${{ secrets.RINOA_GITEA_PUBLIC_SSH_KEY }}
ssh_private_key: ${{ secrets.RINOA_GITEA_PRIVATE_SSH_KEY }}
- 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: Docker Compose Deployment @ Rinoa'
notification_message: 'Deployment completed successfully.'
+6 -6
View File
@@ -2004,12 +2004,12 @@ services:
timeout: 5s timeout: 5s
image: alangrainger/immich-public-proxy:latest image: alangrainger/immich-public-proxy:latest
labels: labels:
homepage: enable swag: enable
homepage_proto: http swag_proto: http
homepage_port: 3000 swag_port: 3000
homepage_url: pics.${MY_TLD} swag_url: pics.${MY_TLD}
homepage.uptime-kuma.enabled: true swag.uptime-kuma.enabled: true
homepage.uptime-kuma.monitor.url: https://pics.${MY_TLD} swag.uptime-kuma.monitor.url: https://pics.${MY_TLD}
homepage.group: Lifestyle homepage.group: Lifestyle
homepage.name: Immich homepage.name: Immich
homepage.href: https://pics.${MY_TLD} homepage.href: https://pics.${MY_TLD}