deploy-playground.yml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. name: Deploy Playground
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. gitRepo:
  6. description: 'Code repository'
  7. required: false
  8. default: 'https://github.com/Joystream/joystream.git'
  9. branchName:
  10. description: 'Branch to deploy'
  11. required: false
  12. default: 'master'
  13. keyName:
  14. description: 'SSH key pair on AWS'
  15. required: false
  16. default: 'joystream-github-action-key'
  17. instanceType:
  18. description: 'AWS EC2 instance type (t2.micro, t2.large)'
  19. required: false
  20. default: 't2.micro'
  21. stackNamePrefix:
  22. description: 'Additional identifier to include in stack name'
  23. required: false
  24. default: 'playground'
  25. # TODO: customDomain instead of ip_address.nip.io
  26. # customDomain:
  27. # description: 'DNS hostname to use for deployment'
  28. # required: false
  29. # default: ''
  30. defaults:
  31. run:
  32. working-directory: devops/aws
  33. jobs:
  34. deploy-playground:
  35. name: Create an EC2 instance and configure docker-compose stack
  36. runs-on: ubuntu-latest
  37. env:
  38. STACK_NAME: ${{ github.event.inputs.stackNamePrefix }}-${{ github.event.inputs.branchName }}-${{ github.run_number }}
  39. steps:
  40. - name: Checkout
  41. uses: actions/checkout@v2
  42. - name: Install Ansible dependencies
  43. run: pipx inject ansible-core boto3 botocore
  44. - name: Configure AWS credentials
  45. uses: aws-actions/configure-aws-credentials@v1
  46. with:
  47. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  48. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  49. aws-region: us-east-1
  50. - name: Deploy to AWS CloudFormation
  51. uses: aws-actions/aws-cloudformation-github-deploy@v1
  52. id: deploy_stack
  53. with:
  54. name: ${{ env.STACK_NAME }}
  55. template: devops/aws/cloudformation/single-instance-docker.yml
  56. no-fail-on-empty-changeset: '1'
  57. parameter-overrides: 'KeyName=${{ github.event.inputs.keyName }},EC2InstanceType=${{ github.event.inputs.instanceType }}'
  58. - name: Run playbook
  59. uses: dawidd6/action-ansible-playbook@v2
  60. with:
  61. playbook: deploy-playground-playbook.yml
  62. directory: devops/aws
  63. requirements: requirements.yml
  64. key: ${{ secrets.SSH_PRIVATE_KEY }}
  65. inventory: |
  66. [all]
  67. ${{ steps.deploy_stack.outputs.PublicIp }}
  68. options: |
  69. --extra-vars "git_repo=${{ github.event.inputs.gitRepo }} \
  70. branch_name=${{ github.event.inputs.branchName }}"