Skip to content

Commit

Permalink
feat: Add workflow to include automatic deployments to staging (#912)
Browse files Browse the repository at this point in the history
* Adds `.github/workflows/deploy-staging.yml` to trigger automatic deploys to staging when `development` is updated

---------

Co-authored-by: jugglinmike <[email protected]>
  • Loading branch information
howard-e and jugglinmike authored Apr 4, 2024
1 parent a6e7a8a commit 226a472
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy to staging

on:
push:
branches:
- development

jobs:
deploy-staging:
runs-on: ubuntu-latest

steps:
- name: Install SSH key for deploying
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS_STAGING }}
config: ${{ secrets.DEPLOY_SSH_CONFIG }}
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install ansible and deploy to staging
run: |
python -m pip install --user ansible-core==2.11.1
cd deploy
echo ${{ secrets.ANSIBLE_VAULT_PASSWORD }} > ansible-vault-password.txt
ansible-vault view --vault-password-file ansible-vault-password.txt files/jwt-signing-key.pem.enc > ../jwt-signing-key.pem
ansible-galaxy collection install ansible.posix
ansible-playbook provision.yml -e ansible_python_interpreter=/usr/bin/python3 --inventory inventory/staging.yml
1 change: 1 addition & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ To deploy this project to server:
export PATH=$PATH:/Users/Luigi/Library/Python/3.9/bin
```
- Run `source ~/.zshrc` to refresh your shell.
- Install `ansible.posix` to make use of the [ansible.posix.synchronize](https://docs.ansible.com/ansible/latest/collections/ansible/posix/synchronize_module.html#ansible-posix-synchronize-module-a-wrapper-around-rsync-to-make-common-tasks-in-your-playbooks-quick-and-easy) module: `ansible-galaxy collection install ansible.posix`
- Run `ansible --version` to verify your ansible is on version 2.11.
5. Execute the following command from the deploy directory:
- Sandbox:
Expand Down
2 changes: 1 addition & 1 deletion deploy/roles/application/tasks/upload-source-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

- name: Upload project source code
block:
- name: Perform source code sychronization
- name: Perform source code synchronization
synchronize:
src: '{{playbook_dir}}/..'
dest: '{{source_dir}}'
Expand Down

0 comments on commit 226a472

Please sign in to comment.