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