--- - name: Fix Gitea Actions Configuration (non-destructive) hosts: production become: no gather_facts: yes tasks: - name: Check current Gitea Actions configuration shell: | docker exec gitea cat /data/gitea/conf/app.ini 2>/dev/null | grep -A 5 "\[actions\]" || echo "No actions section found" register: current_config changed_when: false ignore_errors: yes - name: Backup existing app.ini shell: | docker exec gitea cp /data/gitea/conf/app.ini /data/gitea/conf/app.ini.backup.$(date +%Y%m%d_%H%M%S) changed_when: false ignore_errors: yes - name: Copy app.ini from container for editing shell: | docker cp gitea:/data/gitea/conf/app.ini /tmp/gitea_app_ini_$$ register: copy_result - name: Update app.ini Actions section shell: | # Remove DEFAULT_ACTIONS_URL line if it exists in [actions] section sed -i '/^\[actions\]/,/^\[/{ /^DEFAULT_ACTIONS_URL/d; }' /tmp/gitea_app_ini_$$ # Ensure ENABLED = true in [actions] section if grep -q "^\[actions\]" /tmp/gitea_app_ini_$$; then # Section exists - ensure ENABLED = true sed -i '/^\[actions\]/,/^\[/{ s/^ENABLED.*/ENABLED = true/; }' /tmp/gitea_app_ini_$$ # If ENABLED line doesn't exist, add it if ! grep -A 10 "^\[actions\]" /tmp/gitea_app_ini_$$ | grep -q "^ENABLED"; then sed -i '/^\[actions\]/a ENABLED = true' /tmp/gitea_app_ini_$$ fi else # Section doesn't exist - add it echo "" >> /tmp/gitea_app_ini_$$ echo "[actions]" >> /tmp/gitea_app_ini_$$ echo "ENABLED = true" >> /tmp/gitea_app_ini_$$ fi args: executable: /bin/bash register: config_updated - name: Copy updated app.ini back to container shell: | docker cp /tmp/gitea_app_ini_$$ gitea:/data/gitea/conf/app.ini rm -f /tmp/gitea_app_ini_$$ when: config_updated.changed | default(false) - name: Verify Actions configuration after update shell: | docker exec gitea cat /data/gitea/conf/app.ini | grep -A 5 "\[actions\]" register: updated_config changed_when: false - name: Restart Gitea to apply configuration shell: | cd {{ stacks_base_path }}/gitea docker compose restart gitea when: config_updated.changed | default(false) - name: Wait for Gitea to be ready wait_for: timeout: 60 when: config_updated.changed | default(false) - name: Display configuration result debug: msg: - "=== Gitea Actions Configuration Fixed ===" - "" - "Current [actions] configuration:" - "{{ updated_config.stdout }}" - "" - "Configuration updated: {{ 'Yes' if config_updated.changed else 'No changes needed' }}" - "Gitea restarted: {{ 'Yes' if config_updated.changed else 'No' }}"