qa #5
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: qa | |
concurrency: | |
group: qa | |
on: | |
workflow_dispatch: | |
jobs: | |
deploy-ec2: | |
name: deploy-ec2-e2e | |
runs-on: ubuntu-latest | |
timeout-minutes: 120 | |
env: | |
AWS_REGION: "us-east-1" | |
QA_AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
QA_AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
ANSIBLE_VAULT_PASSWORD: ${{ secrets.ANSIBLE_VAULT_PASSWORD }} | |
BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} | |
QA_GITHUB_TOKEN: ${{ secrets.QA_GITHUB_TOKEN }} | |
ANSIBLE_HOST_KEY_CHECKING: "false" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install Ansible and Dependencies | |
run: pip install boto boto3 ansible-vault ansible-core | |
- name: Install amazon.aws Ansible library | |
run: ansible-galaxy collection install amazon.aws | |
- name: SSH key setup | |
run: | | |
mkdir ~/.ssh/ | |
echo "${{ secrets.QA_ANSIBLE_SSH_KEY }}" > ~/.ssh/id_rsa | |
chmod 0400 ~/.ssh/id_rsa | |
- name: Run Playbook to initialize the EC2 instance | |
run: | | |
ansible-playbook -i deploy/ansible/inventory.txt \ | |
deploy/ansible/deploy-ec2.yml | |
- name: Run Playbook to install worker node prerequisites | |
run: | | |
ansible-galaxy install -r requirements.yml | |
ansible-playbook -i deploy/ansible/inventory.txt deploy/ansible/deploy-worker-prereqs.yml | |
- name: Build and deploy the worker image | |
run: | | |
echo "${ANSIBLE_VAULT_PASSWORD}" > ansible_vault_password_file | |
ansible-playbook -i deploy/ansible/inventory.txt \ | |
-e "qa_github_token=${QA_GITHUB_TOKEN}" \ | |
--vault-password-file ansible_vault_password_file \ | |
deploy/ansible/qa/build-worker/build-worker-img.yml | |
# - name: Deploy the bot container | |
# run: | | |
# echo "${ANSIBLE_VAULT_PASSWORD}" > ansible_vault_password_file | |
# ansible-playbook -i deploy/ansible/inventory.txt -e @secrets.enc \ | |
# --vault-password-file ansible_vault_password_file \ | |
# -e "github_token=${BOT_GITHUB_TOKEN}" deploy/ansible/deploy-bot.yml | |
# rm -f ansible_vault_password_file | |
- name: Terminate EC2 Instances | |
if: always() | |
run: | | |
ansible-playbook deploy/ansible/qa/terminate-qa/terminate-qa.yml |