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: 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example expects trellis and the website to live in separate repo's. You can remove step
Move site to subdirectory
andClone 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: