test pipeline

This commit is contained in:
2026-01-23 19:26:53 +01:00
parent 2281b80980
commit 357f6fb755

View File

@@ -16,6 +16,11 @@
- debug: - debug:
var: git_result var: git_result
- name: Check if .env exists
stat:
path: "{{ prod_base_dir }}/.env"
register: env_file
- name: Download and installs all libs and dependencies - name: Download and installs all libs and dependencies
community.general.composer: community.general.composer:
command: install command: install
@@ -38,11 +43,13 @@
command: "keyhelp-php84 artisan config:clear" command: "keyhelp-php84 artisan config:clear"
args: args:
chdir: "{{ prod_base_dir }}" chdir: "{{ prod_base_dir }}"
when: env_file.stat.exists
- name: Clear application cache - name: Clear application cache
command: "keyhelp-php84 artisan cache:clear" command: "keyhelp-php84 artisan cache:clear"
args: args:
chdir: "{{ prod_base_dir }}" chdir: "{{ prod_base_dir }}"
when: env_file.stat.exists
- name: Create database backup directory - name: Create database backup directory
file: file:
@@ -60,10 +67,12 @@
mysqldump -u "$DB_USERNAME" -p"$DB_PASSWORD" "$DB_DATABASE" > "$BACKUP_FILE" mysqldump -u "$DB_USERNAME" -p"$DB_PASSWORD" "$DB_DATABASE" > "$BACKUP_FILE"
echo "$BACKUP_FILE" echo "$BACKUP_FILE"
register: backup_result register: backup_result
when: env_file.stat.exists
- name: Display backup location - name: Display backup location
debug: debug:
msg: "Database backed up to: {{ backup_result.stdout }}" msg: "Database backed up to: {{ backup_result.stdout }}"
when: env_file.stat.exists
- name: Run database migrations safely - name: Run database migrations safely
command: "keyhelp-php84 artisan migrate:safe --force" command: "keyhelp-php84 artisan migrate:safe --force"
@@ -71,21 +80,25 @@
chdir: "{{ prod_base_dir }}" chdir: "{{ prod_base_dir }}"
register: migrate_result register: migrate_result
failed_when: migrate_result.rc != 0 failed_when: migrate_result.rc != 0
when: env_file.stat.exists
- name: Display migration result - name: Display migration result
debug: debug:
var: migrate_result var: migrate_result
when: env_file.stat.exists
- name: Remove old database backups (keep last 10) - name: Remove old database backups (keep last 10)
shell: | shell: |
cd {{ prod_base_dir }}/backups cd {{ prod_base_dir }}/backups
ls -t db_backup_*.sql | tail -n +11 | xargs -r rm ls -t db_backup_*.sql | tail -n +11 | xargs -r rm
ignore_errors: yes ignore_errors: yes
when: env_file.stat.exists
- name: Run version fetch command - name: Run version fetch command
command: "keyhelp-php84 artisan version:fetch" command: "keyhelp-php84 artisan version:fetch"
args: args:
chdir: "{{ prod_base_dir }}" chdir: "{{ prod_base_dir }}"
when: env_file.stat.exists
- name: Reload PHP-FPM to clear OPcache - name: Reload PHP-FPM to clear OPcache
command: sudo /usr/bin/systemctl reload keyhelp-php84-fpm.service command: sudo /usr/bin/systemctl reload keyhelp-php84-fpm.service