Skip to content

Instantly share code, notes, and snippets.

@rossbulat
Created July 26, 2019 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossbulat/e907790823b35834114eed645b9dcf93 to your computer and use it in GitHub Desktop.
Save rossbulat/e907790823b35834114eed645b9dcf93 to your computer and use it in GitHub Desktop.
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