Last active
June 7, 2020 15:13
-
-
Save roelofjan-elsinga/84bf1c1fa58ecfa95e18a5174bdd0f14 to your computer and use it in GitHub Desktop.
A sample Ansible playbook to deploy changes to a Laravel application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: roelofjanelsinga.com # You can also specify an IP address | |
vars_files: | |
- secrets.yml # Contains the github_user and github_token variable | |
vars: # Define new variables | |
github_repo_url: https://{{github_user}}:{{github_token}}@github.com/roelofjan-elsinga/portfolio.git | |
working_directory: /path/to/app | |
tasks: | |
- name: "Pull changes from GitHub" | |
git: | |
repo: "{{github_repo_url}}", # This is how we can make this step reusable across projects | |
dest: "{{working_directory}}" | |
version: master # Branch to pull | |
accept_hostkey: yes | |
register: repo # Store the result of this task in a variable | |
- name: "Install Composer dependencies" | |
script: composer install --no-scripts --no-dev | |
when: repo.changed # Only run this step if we actually pulled new changes from GitHub | |
- name: "Cache the configuration" | |
script: "php artisan config:cache" | |
when: repo.changed # Only run if we pulled changes | |
- name: "Clear the view cache" | |
script: "php artisan view:clear" | |
when: repo.changed # Only run if we pulled changes | |
- name: "Run the migrations" | |
script: "php artisan migrate --force" | |
when: repo.changed # Only run if we pulled changes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment