Skip to content

Commit b5a5aa1

Browse files
Fix workflow directory path for GitHub Actions
1 parent c589965 commit b5a5aa1

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy Portfolio to Azure
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.10'
20+
21+
- name: Install Ansible
22+
run: pip install ansible
23+
24+
- name: Generate Ansible Secrets File
25+
run: |
26+
mkdir -p configuration/vars
27+
cat << EOF >> configuration/cars/secrets.yml
28+
env_secret_key: "${{ secrets.DJANGO_SECRET_KEY }}"
29+
env_debug: "${{ secrets.DJANGO_DEBUG }}"
30+
env_allowed_hosts: "${{ secrets.DJANGO_ALLOWED_HOSTS }}"
31+
env_email_host_user: "${{ secrets.EMAIL_HOST_USER }}"
32+
env_email_host_password: "${{ secrets.EMAIL_HOST_PASSWORD }}"
33+
EOF
34+
35+
- name: Set up SSH Access to Azure VM
36+
run: |
37+
mkdir -p ~/.ssh
38+
echo "${{ secrets.AZURE_VM_SSH_KEY }}" > ~/.ssh/id_rsa
39+
chmod 600 ~/.ssh/id_rsa
40+
ssh-keyscan -H ${{ secrets.AZURE_VM_IP }} >> ~/.ssh/known_hosts
41+
42+
- name: Execute Ansible Deploy Playbook
43+
env:
44+
ANSIBLE_HOST_KEY_CHECKING: "False"
45+
run: |
46+
cd configuration
47+
ansible-playbook -i "${{ secrets.AZURE_VM_IP }}," -u azureuser --private-key ~/.ssh/id_rsa deploy.yml

0 commit comments

Comments
 (0)