Skip to content

Instantly share code, notes, and snippets.

@Xilonz
Created October 30, 2019 22:48
Show Gist options
  • Save Xilonz/bbeeb603147fe89fd5af38d5e2b27231 to your computer and use it in GitHub Desktop.
Save Xilonz/bbeeb603147fe89fd5af38d5e2b27231 to your computer and use it in GitHub Desktop.
Roots Trellis Github Actions Example
name: Deploy
on: [push]
jobs:
deploy_staging:
name: deploy to staging
runs-on: ubuntu-latest
container:
image: itinerisltd/tiller:latest
env:
ANSIBLE_HOST_KEY_CHECKING: false
# TODO: Customize these environment variables
SITE_ENV: staging
SITE_KEY: example.com
SITE_LOCAL_PATH: site
TRELLIS_BRANCH: master
TRELLIS_REPO: git@github.com:roots/trellis.git
steps:
- uses: webfactory/ssh-agent@v0.1.1
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- uses: actions/checkout@master
- name: Move site to subdirectory
run: |
mv $GITHUB_WORKSPACE /tmp/repo
mkdir -p $GITHUB_WORKSPACE
mv /tmp/repo $GITHUB_WORKSPACE/$SITE_LOCAL_PATH
- name: Clone Trellis Repo
run: git clone --verbose --branch $TRELLIS_BRANCH --depth 1 $TRELLIS_REPO $GITHUB_WORKSPACE/trellis
- name: Set Ansible Vault Pass
run: echo ${{ secrets.vault_pass }} > .vault_pass
working-directory: trellis
- name: Install Ansible Galaxy Roles
run: ansible-galaxy install -r requirements.yml -vvvv
working-directory: trellis
- name: Deploy
run: ansible-playbook deploy.yml -e env=$SITE_ENV -e site=$SITE_KEY -e site_version=$GITHUB_SHA -vvvv
working-directory: trellis
@tangrufus
Copy link

@Xilonz
Copy link
Author

Xilonz commented Oct 31, 2019

@tangrufus
Copy link

tangrufus commented Oct 31, 2019

I am stupid... I forgot there is documentation...

@Xilonz
Copy link
Author

Xilonz commented Oct 31, 2019

This example expects trellis and the website to live in separate repo's. You can remove step Move site to subdirectory and Clone Trellis Repo if you have trellis and bedrock in the same dir. If you want then to only deploy on changes in the site folder:

on:
  push:
    paths:
    - 'site/*'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment