Created
October 30, 2019 22:48
-
-
Save Xilonz/bbeeb603147fe89fd5af38d5e2b27231 to your computer and use it in GitHub Desktop.
Roots Trellis Github Actions Example
This file contains 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
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: [email protected]:roots/trellis.git | |
steps: | |
- uses: webfactory/[email protected] | |
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 |
Correct, you can follow these parts on the circle-ci tiller guide: https://github.com/TypistTech/tiller-circleci#ensure-trellis-deploys-the-correct-commit and https://github.com/TypistTech/tiller-circleci#ansible-vault-password
I am stupid... I forgot there is documentation...
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
Note: To make
-e site_version=$GITHUB_SHA
work, you have to change this line https://github.com/roots/trellis/blob/c279a99335e90f5226dcb842f798c4849e0ffe57/group_vars/production/wordpress_sites.yml#L14