deploy-playground.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. defaults:
  22. run:
  23. working-directory: devops/aws
  24. jobs:
  25. deploy-playground:
  26. name: Create an EC2 instance and configure docker-compose stack
  27. runs-on: ubuntu-latest
  28. env:
  29. STACK_NAME: joystream-playground-${{ github.event.inputs.branchName }}-${{ github.run_number }}
  30. steps:
  31. - name: Checkout
  32. uses: actions/checkout@v2
  33. - name: Install Ansible dependencies
  34. run: pipx inject ansible-core boto3 botocore
  35. - name: Configure AWS credentials
  36. uses: aws-actions/configure-aws-credentials@v1
  37. with:
  38. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  39. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  40. aws-region: us-east-1
  41. - name: Deploy to AWS CloudFormation
  42. uses: aws-actions/aws-cloudformation-github-deploy@v1
  43. id: deploy_stack
  44. with:
  45. name: ${{ env.STACK_NAME }}
  46. template: devops/aws/cloudformation/single-instance-docker.yml
  47. no-fail-on-empty-changeset: '1'
  48. parameter-overrides: 'KeyName=${{ github.event.inputs.keyName }},EC2InstanceType=${{ github.event.inputs.instanceType }}'
  49. - name: Run playbook
  50. uses: dawidd6/action-ansible-playbook@v2
  51. with:
  52. playbook: deploy-playground-playbook.yml
  53. directory: devops/aws
  54. requirements: requirements.yml
  55. key: ${{ secrets.SSH_PRIVATE_KEY }}
  56. inventory: |
  57. [all]
  58. ${{ steps.deploy_stack.outputs.PublicIp }}
  59. options: |
  60. --extra-vars "git_repo=${{ github.event.inputs.gitRepo }} \
  61. branch_name=${{ github.event.inputs.branchName }}"