Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ansible Github Deployment Playbook
# Github -> Production Deployment
#
# Change vars to point to your own folders
# These folders should exist on your production servers
---
- name: React App Deployment from Github Repository
connection: ssh
gather_facts: false
hosts: all
vars:
repo_folder: /var/deployment/repos/repository-name
live_folder: /var/deployment/mydomain.com/build
repo_name: username/repository-name
tasks:
- git:
repo: ssh://git@github.com/{{ repo_name }}.git
dest: "{{ repo_folder }}"
update: yes
- name: Install dependencies
yarn:
path: "{{ repo_folder }}"
- name: Build project
command: yarn build
args:
chdir: "{{ repo_folder }}"
- name: Copy build to live directory
command: cp -TRv build {{ live_folder }}
args:
chdir: "{{ repo_folder }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment